Skip to content

Commit

Permalink
#95 Update Netlify CMS to 2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Quicksaver committed Jan 9, 2019
1 parent 68e6208 commit 31d3546
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 38 deletions.
7 changes: 6 additions & 1 deletion js/admin/bodyClassLogin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
(() => {
const SELECTORS = {
// container: '.nc-app-container', // Netlify-cms 1.9.2
container: '.notif__container',
};

const findAppContainer = () => {
const nodes = document.querySelectorAll('.nc-app-container');
const nodes = document.querySelectorAll(SELECTORS.container);
if (nodes.length > 0) {
document.body.classList.add('logged-in');
}
Expand Down
11 changes: 9 additions & 2 deletions js/admin/hiddenStringFields.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
(() => {
const SELECTORS = {
// control: '.nc-controlPane-control', // Netlify-cms 1.9.2
// label: '.nc-controlPane-label', // Netlify-cms 1.9.2
control: '.ei073ck0',
label: '.css-1skqem4',
};

const findHiddenStrings = () => {
document.querySelectorAll('.nc-controlPane-control').forEach((field) => {
field.querySelectorAll('.nc-controlPane-label').forEach((label) => {
document.querySelectorAll(SELECTORS.control).forEach((field) => {
field.querySelectorAll(SELECTORS.label).forEach((label) => {
if (label.textContent === '[hidden]') {
field.hidden = true;
}
Expand Down
17 changes: 12 additions & 5 deletions js/admin/languageSelector.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { ucs2 } from 'punycode';

(() => {
const SELECTORS = {
// heading: 'h1.nc-collectionPage-sidebarHeading', // Netlify-cms 1.9.2
// link: '.nc-collectionPage-sidebarLink', // Netlify-cms 1.9.2
heading: '.el9l68m1',
link: '.el9l68m4 > li',
};

const findH1 = (target) => {
const h1 = target && target.querySelectorAll('h1.nc-collectionPage-sidebarHeading')[0];
const h1 = target && target.querySelector(SELECTORS.heading);
if (h1) {
const locales = [];
let select = null;

const items = document.querySelectorAll('.nc-collectionPage-sidebarLink');
const items = document.querySelectorAll(SELECTORS.link);
items.forEach((item) => {
const chunks = item.textContent.split(' ');
chunks.forEach((chunk) => {
Expand Down Expand Up @@ -44,9 +51,9 @@ import { ucs2 } from 'punycode';
});

// Show the locale selector only when there are enough locales for it to be useful.
if (locales.length > 1 && !h1.querySelectorAll('.nc-collectionPage-localeSelector').length) {
if (locales.length > 1 && !h1.querySelectorAll('.custom-locale-selector').length) {
select = document.createElement('select');
select.classList.add('nc-collectionPage-localeSelector');
select.classList.add('custom-locale-selector');

locales.forEach((locale) => {
const option = document.createElement('option');
Expand All @@ -60,7 +67,7 @@ import { ucs2 } from 'punycode';
// Changing the selector should update the shown content types according to the selection.
select._onChange = () => {
const locale = select.value;
const links = document.querySelectorAll('.nc-collectionPage-sidebarLink');
const links = document.querySelectorAll(SELECTORS.link);
links.forEach((link) => {
if (link.classList.contains(`locale-${locale}`)) {
link.classList.remove('locale-hidden');
Expand Down
68 changes: 40 additions & 28 deletions scss/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,37 @@
* Locale selector.
*/

.nc-collectionPage {
&-localeSelector {
font-size: 16px;
height: 1.75em;
position: absolute;
right: -3px;
top: 50%;
transform: translateY(-50%);
width: 3em;
}

&-sidebarHeading {
position: relative;
}
.custom-locale-selector {
font-size: 16px;
height: 1.75em;
position: absolute;
right: -3px;
top: 50%;
transform: translateY(-50%);
width: 3em;
}

&-sidebarLink {
&.locale-hidden {
display: none;
}
// .nc-collectionPage-sidebarHeading { Netlify-cms 1.9.2
.el9l68m1 {
position: relative;
}

&:first-of-type {
margin-top: 0;
}
// .nc-collectionPage-sidebarLink { // Netlify-cms 1.9.2
.el9l68m4 > li {
&.locale-hidden {
display: none;
}

&-sidebarSearch {
margin-bottom: 16px;
&:first-of-type {
margin-top: 0;
}
}

// .nc-collectionPage-sidebarSearch { // Netlify-cms 1.9.2
.el9l68m2 {
margin-bottom: 16px;
}

/*
* Custom login message
*/
Expand Down Expand Up @@ -126,16 +127,27 @@
}
}

.nc-githubAuthenticationPage-logo {
// .nc-githubAuthenticationPage-logo { // Netlify-cms 1.9.2
.e4hp3ji2 {
display: none;
}

.nc-githubAuthenticationPage-button {
// .nc-githubAuthenticationPage-button { // Netlify-cms 1.9.2
.e4hp3ji4 {
margin-top: 0;
}

.nc-entryEditor-containerOuter {
.logged-in & {
padding-bottom: 40px;
.logged-in {
// .nc-entryEditor-containerOuter { // Netlify-cms 1.9.2
.e1pxf6c40 {
padding-bottom: 44px;
}

.el9l68m0 {
max-height: calc(100vh - 132px);
}

.e1yhfkro1 {
padding-bottom: 20px;
}
}
3 changes: 1 addition & 2 deletions static/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Content Manager</title>

<link rel="stylesheet" href="https://unpkg.com/netlify-cms@1.9.2/dist/cms.css" />
<link rel="stylesheet" href="../css/admin.css" />
</head>
<body>
Expand All @@ -24,7 +23,7 @@ <h3 class="custom-login-message__title">
</div>
<!-- custom login message -->

<script src="https://unpkg.com/netlify-cms@1.9.2/dist/cms.js"></script>
<script src="https://unpkg.com/netlify-cms@2.3.1/dist/netlify-cms.js"></script>
<script src="../js/app.min.js"></script>
<script src="main.min.js"></script>
</body>

0 comments on commit 31d3546

Please sign in to comment.