diff --git a/src/css/base.css b/src/css/base.css index d0fdaaec..9838b622 100644 --- a/src/css/base.css +++ b/src/css/base.css @@ -22,6 +22,7 @@ body { font-family: var(--body-font-family); line-height: var(--body-line-height); margin: 0; + tab-size: 4; word-wrap: anywhere; /* aka overflow-wrap; used when hyphens are disabled or aren't sufficient */ } diff --git a/src/css/vendor/asciidoctor-tabs.css b/src/css/vendor/asciidoctor-tabs.css index 8044104a..920001d8 100644 --- a/src/css/vendor/asciidoctor-tabs.css +++ b/src/css/vendor/asciidoctor-tabs.css @@ -44,12 +44,12 @@ content: none; } +.doc .tabs:not(.is-loading) .tablist > ul li { + transition: background-color 200ms ease-in-out, color 100ms linear; +} + .doc .tabpanel { background-color: initial; border: 0; padding: 0; } - -html.theme-set .doc .tabs .tablist > ul li { - transition: background-color 200ms ease-in-out, color 100ms linear; -} diff --git a/src/js/07-switch-theme.js b/src/js/07-switch-theme.js new file mode 100644 index 00000000..9547aa2d --- /dev/null +++ b/src/js/07-switch-theme.js @@ -0,0 +1,35 @@ +/* + * Copyright 2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +;(function () { + 'use strict' + + activateSwitch(document.getElementById('switch-theme-checkbox')) + + function activateSwitch (control) { + if (!control) return + control.checked = document.documentElement.classList.contains('dark-theme') + control.addEventListener('change', onThemeChange.bind(control)) + } + + function onThemeChange () { + document.documentElement.classList.toggle('dark-theme', this.checked) + saveTheme(this.checked ? 'dark' : 'light') + } + + function saveTheme (theme) { + window.localStorage && window.localStorage.setItem('theme', theme) + } +})() diff --git a/src/js/vendor/switchtheme.js b/src/js/vendor/switchtheme.js deleted file mode 100644 index 7846c94c..00000000 --- a/src/js/vendor/switchtheme.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -;(function () { - 'use strict' - - const localStorage = window.localStorage - const htmlElement = document.documentElement - const prefersDarkColorScheme = window.matchMedia('(prefers-color-scheme: dark)') - - swithInitialTheme() - window.addEventListener('load', onWindowLoad) - - function swithInitialTheme () { - if (isInitialThemeDark()) htmlElement.classList.add('dark-theme') - window.requestAnimationFrame(function () { - htmlElement.classList.add('theme-set') - }) - } - - function onWindowLoad () { - const toggleCheckboxElement = document.querySelector('#switch-theme-checkbox') - toggleCheckboxElement.checked = isInitialThemeDark() - toggleCheckboxElement.addEventListener('change', onThemeChange.bind(toggleCheckboxElement)) - } - - function isInitialThemeDark () { - const theme = loadTheme() - return theme ? theme === 'dark' : prefersDarkColorScheme.matches - } - - function onThemeChange () { - if (this.checked) { - htmlElement.classList.add('dark-theme') - saveTheme('dark') - } else { - htmlElement.classList.remove('dark-theme') - saveTheme('light') - } - } - - function saveTheme (theme) { - if (localStorage) localStorage.setItem('theme', theme) - } - - function loadTheme () { - if (localStorage != null) return localStorage.getItem('theme') - } -})() diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 16ba1905..4403bdaf 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -1,7 +1,6 @@ - {{#if env.ALGOLIA_API_KEY}} {{/if}} diff --git a/src/partials/head-styles.hbs b/src/partials/head-styles.hbs index 44c9562d..5dabc0bd 100644 --- a/src/partials/head-styles.hbs +++ b/src/partials/head-styles.hbs @@ -1,3 +1,8 @@ +