From f6c25f720559a40cb7659138934b2a0b61cf6990 Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 6 Jan 2024 01:35:22 +0100 Subject: [PATCH 1/8] Added darkmode Added an option to have a darkmode in the documentation. The option is based on the implementation from GoogleChromeLabs https://github.com/GoogleChromeLabs/dark-mode-toggle. At the moment this option is only available if using the W3CStyle. --- src/main/java/widoco/Constants.java | 42 +- src/main/java/widoco/CreateResources.java | 12 + .../resources/darkmode/dark-mode-toggle.mjs | 372 ++++++++++++++++++ src/main/resources/darkmode/dark.css | 18 + src/main/resources/darkmode/light.css | 17 + src/main/resources/darkmode/moon.svg | 7 + src/main/resources/darkmode/slider.css | 78 ++++ src/main/resources/darkmode/sun.svg | 5 + src/main/resources/lode/extra.css | 17 +- src/main/resources/lode/lodeprimer.css | 2 +- src/main/resources/lode/owl.css | 6 +- src/main/resources/lode/rec.css | 14 +- 12 files changed, 557 insertions(+), 33 deletions(-) create mode 100644 src/main/resources/darkmode/dark-mode-toggle.mjs create mode 100644 src/main/resources/darkmode/dark.css create mode 100644 src/main/resources/darkmode/light.css create mode 100644 src/main/resources/darkmode/moon.svg create mode 100644 src/main/resources/darkmode/slider.css create mode 100644 src/main/resources/darkmode/sun.svg diff --git a/src/main/java/widoco/Constants.java b/src/main/java/widoco/Constants.java index 10fcd0c7..c569c1d5 100644 --- a/src/main/java/widoco/Constants.java +++ b/src/main/java/widoco/Constants.java @@ -732,16 +732,11 @@ public static String getIndexDocument(String resourcesFolderName, Configuration String document = OPENING; /* Style selection */ if (c.isUseW3CStyle()) { - document += " \n" + - " \n" + " \n" + " \n"; + document += getW3CStyleDoc(resourcesFolderName); } else { - document += " \n" - + " \n"; + document += htmlStyleSheet(resourcesFolderName+"/yeti.css","screen") + +htmlStyleSheet(resourcesFolderName+"/site.css","screen"); } // add a favicon (rdf logo) document += ""; @@ -862,7 +857,25 @@ public static String getIndexDocument(String resourcesFolderName, Configuration return document; } - + + private static String htmlStyleSheet(String resource,String media) { + return "\n"; + } + + private static String getW3CStyleDoc(String rsrcFolder){ + return htmlStyleSheet(rsrcFolder+"/primer.css","screen") + + htmlStyleSheet(rsrcFolder+"/rec.css","screen") + + htmlStyleSheet(rsrcFolder+"/extra.css","screen") + + htmlStyleSheet(rsrcFolder+"/owl.css","screen") + + htmlStyleSheet(rsrcFolder+"/dark.css","(prefers-color-scheme: dark)") + + htmlStyleSheet(rsrcFolder+"/light.css","(prefers-color-scheme: light)") + + htmlStyleSheet(rsrcFolder+"/slider.css","screen") + + "\n" + + "" + +"
\n" + +"\t\n" + +"
\n"; + } /** * Function that includes all the sections as part of the index document. * This makes the documentation more difficult to edit, but simpler for production @@ -884,14 +897,11 @@ public static String getUnifiedIndexDocument(String resourcesFolderName, Configu String document = OPENING; /* Style selection */ if (c.isUseW3CStyle()) { - document += " " + " " + " " + " "; + document += getW3CStyleDoc(resourcesFolderName); + } else { - document += " " - + " "; + document += htmlStyleSheet(resourcesFolderName+"/yeti.css","screen") + +htmlStyleSheet(resourcesFolderName+"/site.css","screen"); } // add a title to the document if (c.getMainOntology().getTitle() != null && !"".equals(c.getMainOntology().getTitle())) diff --git a/src/main/java/widoco/CreateResources.java b/src/main/java/widoco/CreateResources.java index 9cfc6416..ecb34925 100644 --- a/src/main/java/widoco/CreateResources.java +++ b/src/main/java/widoco/CreateResources.java @@ -477,6 +477,18 @@ private static void createFolderStructure(String s, Configuration c, Properties new File(resources.getAbsolutePath() + File.separator + "extra.css")); WidocoUtils.copyLocalResource("/lode/owl.css", new File(resources.getAbsolutePath() + File.separator + "owl.css")); + WidocoUtils.copyLocalResource("/darkmode/dark.css", + new File(resources.getAbsolutePath() + File.separator + "dark.css")); + WidocoUtils.copyLocalResource("/darkmode/light.css", + new File(resources.getAbsolutePath() + File.separator + "light.css")); + WidocoUtils.copyLocalResource("/darkmode/slider.css", + new File(resources.getAbsolutePath() + File.separator + "slider.css")); + WidocoUtils.copyLocalResource("/darkmode/dark-mode-toggle.mjs", + new File(resources.getAbsolutePath() + File.separator + "dark-mode-toggle.mjs")); + WidocoUtils.copyLocalResource("/darkmode/sun.svg", + new File(resources.getAbsolutePath() + File.separator + "sun.svg")); + WidocoUtils.copyLocalResource("/darkmode/moon.svg", + new File(resources.getAbsolutePath() + File.separator + "moon.svg")); } else { WidocoUtils.copyLocalResource("/lode/bootstrap-yeti.css", new File(resources.getAbsolutePath() + File.separator + "yeti.css")); diff --git a/src/main/resources/darkmode/dark-mode-toggle.mjs b/src/main/resources/darkmode/dark-mode-toggle.mjs new file mode 100644 index 00000000..e6fda594 --- /dev/null +++ b/src/main/resources/darkmode/dark-mode-toggle.mjs @@ -0,0 +1,372 @@ +/** + * Copyright 2019 Google LLC + * + * 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. + */ + +// @license © 2019 Google LLC. Licensed under the Apache License, Version 2.0. +const doc = document; +let store = {}; +try { + store = localStorage; +} catch (err) { + // Do nothing. The user probably blocks cookies. +} +const PREFERS_COLOR_SCHEME = 'prefers-color-scheme'; +const MEDIA = 'media'; +const LIGHT = 'light'; +const DARK = 'dark'; +const MQ_DARK = `(${PREFERS_COLOR_SCHEME}:${DARK})`; +const MQ_LIGHT = `(${PREFERS_COLOR_SCHEME}:${LIGHT})`; +const LINK_REL_STYLESHEET = 'link[rel=stylesheet]'; +const REMEMBER = 'remember'; +const LEGEND = 'legend'; +const TOGGLE = 'toggle'; +const SWITCH = 'switch'; +const APPEARANCE = 'appearance'; +const PERMANENT = 'permanent'; +const MODE = 'mode'; +const COLOR_SCHEME_CHANGE = 'colorschemechange'; +const PERMANENT_COLOR_SCHEME = 'permanentcolorscheme'; +const ALL = 'all'; +const NOT_ALL = 'not all'; +const NAME = 'dark-mode-toggle'; +const DEFAULT_URL = 'https://googlechromelabs.github.io/dark-mode-toggle/demo/'; + +// See https://html.spec.whatwg.org/multipage/common-dom-interfaces.html ↵ +// #reflecting-content-attributes-in-idl-attributes. +const installStringReflection = (obj, attrName, propName = attrName) => { + Object.defineProperty(obj, propName, { + enumerable: true, + get() { + const value = this.getAttribute(attrName); + return value === null ? '' : value; + }, + set(v) { + this.setAttribute(attrName, v); + }, + }); +}; + +const installBoolReflection = (obj, attrName, propName = attrName) => { + Object.defineProperty(obj, propName, { + enumerable: true, + get() { + return this.hasAttribute(attrName); + }, + set(v) { + if (v) { + this.setAttribute(attrName, ''); + } else { + this.removeAttribute(attrName); + } + }, + }); +}; + +const template = doc.createElement('template'); +// ⚠️ Note: this is a minified version of `src/template-contents.tpl`. +// Compress the CSS with https://cssminifier.com/, then paste it here. +// eslint-disable-next-line max-len +template.innerHTML = `
`; + +export class DarkModeToggle extends HTMLElement { + static get observedAttributes() { + return [MODE, APPEARANCE, PERMANENT, LEGEND, LIGHT, DARK, REMEMBER]; + } + + constructor() { + super(); + + installStringReflection(this, MODE); + installStringReflection(this, APPEARANCE); + installStringReflection(this, LEGEND); + installStringReflection(this, LIGHT); + installStringReflection(this, DARK); + installStringReflection(this, REMEMBER); + + installBoolReflection(this, PERMANENT); + + this._darkCSS = null; + this._lightCSS = null; + + doc.addEventListener(COLOR_SCHEME_CHANGE, (event) => { + this.mode = event.detail.colorScheme; + this._updateRadios(); + this._updateCheckbox(); + }); + + doc.addEventListener(PERMANENT_COLOR_SCHEME, (event) => { + this.permanent = event.detail.permanent; + this._permanentCheckbox.checked = this.permanent; + }); + + this._initializeDOM(); + } + + _initializeDOM() { + const shadowRoot = this.attachShadow({mode: 'open'}); + shadowRoot.append(template.content.cloneNode(true)); + + // We need to support `media="(prefers-color-scheme: dark)"` (with space) + // and `media="(prefers-color-scheme:dark)"` (without space) + this._darkCSS = doc.querySelectorAll( + `${LINK_REL_STYLESHEET}[${MEDIA}*=${PREFERS_COLOR_SCHEME}][${MEDIA}*="${DARK}"]`, + ); + this._lightCSS = doc.querySelectorAll( + `${LINK_REL_STYLESHEET}[${MEDIA}*=${PREFERS_COLOR_SCHEME}][${MEDIA}*="${LIGHT}"]`, + ); + + // Get DOM references. + this._lightRadio = shadowRoot.querySelector('[part=lightRadio]'); + this._lightLabel = shadowRoot.querySelector('[part=lightLabel]'); + this._darkRadio = shadowRoot.querySelector('[part=darkRadio]'); + this._darkLabel = shadowRoot.querySelector('[part=darkLabel]'); + this._darkCheckbox = shadowRoot.querySelector('[part=toggleCheckbox]'); + this._checkboxLabel = shadowRoot.querySelector('[part=toggleLabel]'); + this._legendLabel = shadowRoot.querySelector('legend'); + this._permanentAside = shadowRoot.querySelector('aside'); + this._permanentCheckbox = shadowRoot.querySelector( + '[part=permanentCheckbox]', + ); + this._permanentLabel = shadowRoot.querySelector('[part=permanentLabel]'); + } + + connectedCallback() { + // Does the browser support native `prefers-color-scheme`? + const hasNativePrefersColorScheme = matchMedia(MQ_DARK).media !== NOT_ALL; + // Listen to `prefers-color-scheme` changes. + if (hasNativePrefersColorScheme) { + matchMedia(MQ_DARK).addListener(({matches}) => { + if (this.permanent) { + return; + } + this.mode = matches ? DARK : LIGHT; + this._dispatchEvent(COLOR_SCHEME_CHANGE, {colorScheme: this.mode}); + }); + } + // Set initial state, giving preference to a remembered value, then the + // native value (if supported), and eventually defaulting to a light + // experience. + let rememberedValue = false; + try { + rememberedValue = store.getItem(NAME); + } catch (err) { + // Do nothing. The user probably blocks cookies. + } + if (rememberedValue && [DARK, LIGHT].includes(rememberedValue)) { + this.mode = rememberedValue; + this._permanentCheckbox.checked = true; + this.permanent = true; + } else if (hasNativePrefersColorScheme) { + this.mode = matchMedia(MQ_LIGHT).matches ? LIGHT : DARK; + } + if (!this.mode) { + this.mode = LIGHT; + } + if (this.permanent && !rememberedValue) { + try { + store.setItem(NAME, this.mode); + } catch (err) { + // Do nothing. The user probably blocks cookies. + } + } + + // Default to toggle appearance. + if (!this.appearance) { + this.appearance = TOGGLE; + } + + // Update the appearance to either of toggle or switch. + this._updateAppearance(); + + // Update the radios + this._updateRadios(); + + // Make the checkbox reflect the state of the radios + this._updateCheckbox(); + + // Synchronize the behavior of the radio and the checkbox. + [this._lightRadio, this._darkRadio].forEach((input) => { + input.addEventListener('change', () => { + this.mode = this._lightRadio.checked ? LIGHT : DARK; + this._updateCheckbox(); + this._dispatchEvent(COLOR_SCHEME_CHANGE, {colorScheme: this.mode}); + }); + }); + this._darkCheckbox.addEventListener('change', () => { + this.mode = this._darkCheckbox.checked ? DARK : LIGHT; + this._updateRadios(); + this._dispatchEvent(COLOR_SCHEME_CHANGE, {colorScheme: this.mode}); + }); + + // Make remembering the last mode optional + this._permanentCheckbox.addEventListener('change', () => { + this.permanent = this._permanentCheckbox.checked; + this._dispatchEvent(PERMANENT_COLOR_SCHEME, { + permanent: this.permanent, + }); + }); + + // Finally update the mode and let the world know what's going on + this._updateMode(); + this._dispatchEvent(COLOR_SCHEME_CHANGE, {colorScheme: this.mode}); + this._dispatchEvent(PERMANENT_COLOR_SCHEME, { + permanent: this.permanent, + }); + } + + attributeChangedCallback(name, oldValue, newValue) { + if (name === MODE) { + if (![LIGHT, DARK].includes(newValue)) { + throw new RangeError(`Allowed values: "${LIGHT}" and "${DARK}".`); + } + // Only show the dialog programmatically on devices not capable of hover + // and only if there is a label + if (matchMedia('(hover:none)').matches && this.remember) { + this._showPermanentAside(); + } + if (this.permanent) { + try { + store.setItem(NAME, this.mode); + } catch (err) { + // Do nothing. The user probably blocks cookies. + } + } + this._updateRadios(); + this._updateCheckbox(); + this._updateMode(); + } else if (name === APPEARANCE) { + if (![TOGGLE, SWITCH].includes(newValue)) { + throw new RangeError(`Allowed values: "${TOGGLE}" and "${SWITCH}".`); + } + this._updateAppearance(); + } else if (name === PERMANENT) { + if (this.permanent) { + if (this.mode) { + try { + store.setItem(NAME, this.mode); + } catch (err) { + // Do nothing. The user probably blocks cookies. + } + } + } else { + try { + store.removeItem(NAME); + } catch (err) { + // Do nothing. The user probably blocks cookies. + } + } + this._permanentCheckbox.checked = this.permanent; + } else if (name === LEGEND) { + this._legendLabel.textContent = newValue; + } else if (name === REMEMBER) { + this._permanentLabel.textContent = newValue; + } else if (name === LIGHT) { + this._lightLabel.textContent = newValue; + if (this.mode === LIGHT) { + this._checkboxLabel.textContent = newValue; + } + } else if (name === DARK) { + this._darkLabel.textContent = newValue; + if (this.mode === DARK) { + this._checkboxLabel.textContent = newValue; + } + } + } + + _dispatchEvent(type, value) { + this.dispatchEvent( + new CustomEvent(type, { + bubbles: true, + composed: true, + detail: value, + }), + ); + } + + _updateAppearance() { + // Hide or show the light-related affordances dependent on the appearance, + // which can be "switch" or "toggle". + const appearAsToggle = this.appearance === TOGGLE; + this._lightRadio.hidden = appearAsToggle; + this._lightLabel.hidden = appearAsToggle; + this._darkRadio.hidden = appearAsToggle; + this._darkLabel.hidden = appearAsToggle; + this._darkCheckbox.hidden = !appearAsToggle; + this._checkboxLabel.hidden = !appearAsToggle; + } + + _updateRadios() { + if (this.mode === LIGHT) { + this._lightRadio.checked = true; + } else { + this._darkRadio.checked = true; + } + } + + _updateCheckbox() { + if (this.mode === LIGHT) { + this._checkboxLabel.style.setProperty( + `--${NAME}-checkbox-icon`, + `var(--${NAME}-light-icon,url("${DEFAULT_URL}moon.png"))`, + ); + this._checkboxLabel.textContent = this.light; + if (!this.light) { + this._checkboxLabel.ariaLabel = DARK; + } + this._darkCheckbox.checked = false; + } else { + this._checkboxLabel.style.setProperty( + `--${NAME}-checkbox-icon`, + `var(--${NAME}-dark-icon,url("${DEFAULT_URL}sun.png"))`, + ); + this._checkboxLabel.textContent = this.dark; + if (!this.dark) { + this._checkboxLabel.ariaLabel = LIGHT; + } + this._darkCheckbox.checked = true; + } + } + + _updateMode() { + if (this.mode === LIGHT) { + this._lightCSS.forEach((link) => { + link.media = ALL; + link.disabled = false; + }); + this._darkCSS.forEach((link) => { + link.media = NOT_ALL; + link.disabled = true; + }); + } else { + this._darkCSS.forEach((link) => { + link.media = ALL; + link.disabled = false; + }); + this._lightCSS.forEach((link) => { + link.media = NOT_ALL; + link.disabled = true; + }); + } + } + + _showPermanentAside() { + this._permanentAside.style.visibility = 'visible'; + setTimeout(() => { + this._permanentAside.style.visibility = 'hidden'; + }, 3000); + } +} + +customElements.define(NAME, DarkModeToggle); diff --git a/src/main/resources/darkmode/dark.css b/src/main/resources/darkmode/dark.css new file mode 100644 index 00000000..28c78dbd --- /dev/null +++ b/src/main/resources/darkmode/dark.css @@ -0,0 +1,18 @@ +:root { + color-scheme: dark; + --bg-status-box: rgb(0, 90, 156); + --background-color: #3e3e42; + --bg-backlink: #c1c1bd; + --text-color: rgb(240 240 240); + --shadow-color: rgb(240 240 240 / 50%); + --accent-color: rgb(0 0 240 / 50%); + --owl-bg-pre: rgb(15 15 15); + --link: white; + --link-visited: gray; + --link-active: blue; + --href-hover: gray; + --bg-hlist: #67676E; + --bg-description:#67676E; + --literal:#00D900; +} + diff --git a/src/main/resources/darkmode/light.css b/src/main/resources/darkmode/light.css new file mode 100644 index 00000000..540cc3b2 --- /dev/null +++ b/src/main/resources/darkmode/light.css @@ -0,0 +1,17 @@ +:root { + color-scheme: light; + --bg-status-box: rgb(0, 90, 156); + --background-color: white; + --bg-backlink: #F4FFFF; + --text-color: rgb(15 15 15); + --shadow-color: rgb(15 15 15 / 50%); + --accent-color: rgb(240 0 0 / 50%); + --owl-bg: #F9F9F9; + --link: #00c; + --link-visited: #609; + --link-active: #c00; + --href-hover: #ffa; + --bg-hlist: #F4FFFF; + --bg-description:rgb(242, 243, 244); + --literal:green; +} diff --git a/src/main/resources/darkmode/moon.svg b/src/main/resources/darkmode/moon.svg new file mode 100644 index 00000000..fad89a4e --- /dev/null +++ b/src/main/resources/darkmode/moon.svg @@ -0,0 +1,7 @@ + + + + moon + + + diff --git a/src/main/resources/darkmode/slider.css b/src/main/resources/darkmode/slider.css new file mode 100644 index 00000000..a6aa55c9 --- /dev/null +++ b/src/main/resources/darkmode/slider.css @@ -0,0 +1,78 @@ +.darkmode { + position: fixed; + left: 0px; + bottom: 0px; +} + +dark-mode-toggle.slider::part(toggleLabel) { + display: inline-block; + position: relative; + height: calc(var(--dark-mode-toggle-icon-size, 1rem) * 2); + width: calc(var(--dark-mode-toggle-icon-size, 1rem) * 3.5); + background-color: #b7bbbd; + border-radius: var(--dark-mode-toggle-icon-size, 1rem); + transition: 0.4s; +} + +dark-mode-toggle.slider[mode="dark"]::part(toggleLabel) { + background-color: #4e5255; +} + +dark-mode-toggle.slider::part(toggleLabel)::before { + display: flex; + align-items: center; + justify-content: center; + position: absolute; + top: calc(var(--dark-mode-toggle-icon-size, 1rem) * 0.25); + left: calc(var(--dark-mode-toggle-icon-size, 1rem) * 0.25); + height: calc(var(--dark-mode-toggle-icon-size, 1rem) * 1.5); + width: calc(var(--dark-mode-toggle-icon-size, 1rem) * 1.5); + border-radius: 100%; + box-shadow: 0 0.15em 0.3em rgb(0 0 0 / 15%), 0 0.2em 0.5em rgb(0 0 0 / 30%); + background-color: #fff; + color: #333; + transition: 0.4s; + content: ""; + background-position: center; + background-size: var(--dark-mode-toggle-icon-size, 1rem); + background-image: var(--dark-mode-toggle-light-icon, url("sun.svg")); + box-sizing: border-box; +} + +dark-mode-toggle.slider[mode="dark"]::part(toggleLabel)::before { + left: calc(100% - var(--dark-mode-toggle-icon-size, 1rem) * 1.75); + border-color: #000; + background-color: #ccc; + color: #000; + background-size: var(--dark-mode-toggle-icon-size, 1rem); + background-image: var(--dark-mode-toggle-dark-icon, url("moon.svg")); + filter: var(--dark-mode-toggle-icon-filter, invert(100%)); + box-shadow: 0 0.5px hsl(0deg 0% 100% / 16%); +} + +dark-mode-toggle.slider::part(toggleLabel)::after { + display: flex; + align-items: center; + justify-content: center; + position: absolute; + top: calc(var(--dark-mode-toggle-icon-size, 1rem) * 0.25); + left: calc(100% - var(--dark-mode-toggle-icon-size, 1rem) * 1.75); + height: calc(var(--dark-mode-toggle-icon-size, 1rem) * 1.5); + width: calc(var(--dark-mode-toggle-icon-size, 1rem) * 1.5); + border-radius: 100%; + color: #333; + content: ""; + background-position: center; + background-size: var(--dark-mode-toggle-icon-size, 1rem); + background-image: var(--dark-mode-toggle-dark-icon, url("moon.svg")); + background-repeat: no-repeat; + box-sizing: border-box; + opacity: 0.5; +} + +dark-mode-toggle.slider[mode="dark"]::part(toggleLabel)::after { + left: calc(var(--dark-mode-toggle-icon-size, 1rem) * 0.25); + background-image: var(--dark-mode-toggle-light-icon, url("sun.svg")); + filter: var(--dark-mode-toggle-icon-filter, invert(100%)); +} + diff --git a/src/main/resources/darkmode/sun.svg b/src/main/resources/darkmode/sun.svg new file mode 100644 index 00000000..0b18941c --- /dev/null +++ b/src/main/resources/darkmode/sun.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/lode/extra.css b/src/main/resources/lode/extra.css index 16689d3f..3ed223ff 100644 --- a/src/main/resources/lode/extra.css +++ b/src/main/resources/lode/extra.css @@ -3,13 +3,13 @@ body { } h1 { - line-height: 110%; + line-height: 110%; } .hlist { border: 1px solid navy; padding:5px; - background-color: #F4FFFF; + background-color: var(--bg-hlist); } .hlist li { @@ -41,6 +41,11 @@ h1 { color:green; } +.type-ep { + cursor:help; + color:mediumpurple; +} + .type-ap { cursor:help; color:maroon; @@ -77,13 +82,13 @@ dt { .description { border-top: 1px dashed gray; border-bottom: 1px dashed gray; - background-color: rgb(242, 243, 244); + background-color: var(--bg-description); margin-top:5px; padding-bottom:5px; } .description dl { - background-color: rgb(242, 243, 244); + background-color: var(--bg-description); } .description ul { @@ -98,7 +103,7 @@ dt { color:black; padding: 2px; border: 1px dotted navy; - background-color: #F4FFFF; + background-color: var(--bg-backlink); } .imageblock { @@ -119,6 +124,6 @@ dt { } .literal { - color:green; + color:var(--literal); font-style:italic; } \ No newline at end of file diff --git a/src/main/resources/lode/lodeprimer.css b/src/main/resources/lode/lodeprimer.css index 3136dac0..5a73ae3a 100644 --- a/src/main/resources/lode/lodeprimer.css +++ b/src/main/resources/lode/lodeprimer.css @@ -84,7 +84,7 @@ div.fssyntax pre, div.rdfxml pre, div.owlxml pre, div.turtle pre, div.manchester /* The actual status box */ .status div { display: block; - background: rgb(0, 90, 156); + background: var(--bg-status-box); color: white; width: 24em; padding-top: 0.3em; diff --git a/src/main/resources/lode/owl.css b/src/main/resources/lode/owl.css index 9c008760..8a7bf08b 100644 --- a/src/main/resources/lode/owl.css +++ b/src/main/resources/lode/owl.css @@ -211,7 +211,7 @@ table.canonicalparsing td.two { /* override mediawiki's beautiful DL styling... */ dl { - background: white; + background: var(--background-color); width: 100%; border: none; margin-top: 0; @@ -240,9 +240,9 @@ color: red /* just copying from wiki, so it stays through TR. Currently affects Primer, at least */ pre { - background-color:#F9F9F9; + background-color: var(--owl-bg); border:1px dashed #2F6FAB; - color:black; + color:var(--text-color); line-height:1.1em; padding:1em; } \ No newline at end of file diff --git a/src/main/resources/lode/rec.css b/src/main/resources/lode/rec.css index d8a1ff2d..aeb4349b 100644 --- a/src/main/resources/lode/rec.css +++ b/src/main/resources/lode/rec.css @@ -11,16 +11,16 @@ body { padding: 2em 1em 2em 70px; margin: 0; font-family: sans-serif; - color: black; - background: white; + color: var(--text-color); + background: var(--background-color); background-position: top left; background-attachment: fixed; background-repeat: no-repeat; counter-reset:section; } -:link { color: #00C; background: transparent } -:visited { color: #609; background: transparent } -a:active { color: #C00; background: transparent } +:link { color: var(--link); background: transparent } +:visited { color: var(--link-visited); background: transparent } +a:active { color: var(--link-active); background: transparent } a:link img, a:visited img { border-style: none } /* no border on img links */ @@ -41,7 +41,7 @@ h3.list:before{counter-increment:subsection;content: counter(section) "." counte h3.list{margin-top: 20px; border-bottom: 0px; } /* background should be transparent, but WebTV has a bug */ -h1, h2, h3 { color: #005A9C; background: white } +h1, h2, h3 { color: #005A9C; background: var(--background-color) } h1 { font: 170% sans-serif } h2 { font: 140% sans-serif } h3 { font: 120% sans-serif } @@ -59,7 +59,7 @@ p.copyright { font-size: small } p.copyright small { font-size: small } @media screen { /* hide from IE3 */ -a[href]:hover { background: #ffa } +a[href]:hover { background: var(--href-hover) } } pre { margin-left: 2em } From 7e18d4c452b0d95369179d33af487dca8ee13d2d Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 6 Jan 2024 11:51:29 +0100 Subject: [PATCH 2/8] darkmode: added color change for type-op and type-ap --- src/main/resources/darkmode/dark.css | 2 ++ src/main/resources/darkmode/light.css | 2 ++ src/main/resources/lode/extra.css | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/resources/darkmode/dark.css b/src/main/resources/darkmode/dark.css index 28c78dbd..7d17e746 100644 --- a/src/main/resources/darkmode/dark.css +++ b/src/main/resources/darkmode/dark.css @@ -14,5 +14,7 @@ --bg-hlist: #67676E; --bg-description:#67676E; --literal:#00D900; + --type-ap: #EB4A4A; + --type-op: #75E1FC; } diff --git a/src/main/resources/darkmode/light.css b/src/main/resources/darkmode/light.css index 540cc3b2..ce9decc1 100644 --- a/src/main/resources/darkmode/light.css +++ b/src/main/resources/darkmode/light.css @@ -14,4 +14,6 @@ --bg-hlist: #F4FFFF; --bg-description:rgb(242, 243, 244); --literal:green; + --type-ap: maroon; + --type-op: navy; } diff --git a/src/main/resources/lode/extra.css b/src/main/resources/lode/extra.css index 3ed223ff..0ae782fb 100644 --- a/src/main/resources/lode/extra.css +++ b/src/main/resources/lode/extra.css @@ -33,7 +33,7 @@ h1 { .type-op { cursor:help; - color:navy; + color:var(--type-op); } .type-dp { @@ -48,7 +48,7 @@ h1 { .type-ap { cursor:help; - color:maroon; + color:var(--type-ap); } .type-ni { From d5991f141de5e1efe3b0130ecdb0aaf8d6a068b2 Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 6 Jan 2024 12:06:06 +0100 Subject: [PATCH 3/8] darkmode: added color for type-dp and changed literal color for contrast to dp --- src/main/resources/darkmode/dark.css | 3 ++- src/main/resources/darkmode/light.css | 1 + src/main/resources/lode/extra.css | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/resources/darkmode/dark.css b/src/main/resources/darkmode/dark.css index 7d17e746..3803a8bc 100644 --- a/src/main/resources/darkmode/dark.css +++ b/src/main/resources/darkmode/dark.css @@ -13,8 +13,9 @@ --href-hover: gray; --bg-hlist: #67676E; --bg-description:#67676E; - --literal:#00D900; + --literal:#49C00D; --type-ap: #EB4A4A; --type-op: #75E1FC; + --type-dp: #75FA32; } diff --git a/src/main/resources/darkmode/light.css b/src/main/resources/darkmode/light.css index ce9decc1..e3a25aa1 100644 --- a/src/main/resources/darkmode/light.css +++ b/src/main/resources/darkmode/light.css @@ -16,4 +16,5 @@ --literal:green; --type-ap: maroon; --type-op: navy; + --type-dp: green; } diff --git a/src/main/resources/lode/extra.css b/src/main/resources/lode/extra.css index 0ae782fb..d72be880 100644 --- a/src/main/resources/lode/extra.css +++ b/src/main/resources/lode/extra.css @@ -38,7 +38,7 @@ h1 { .type-dp { cursor:help; - color:green; + color:var(--type-dp); } .type-ep { From 9c1f746b1a87fe13da4c4b3eb9b505366535fa2d Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 6 Jan 2024 12:21:01 +0100 Subject: [PATCH 4/8] darkmode: improved contrast for links --- src/main/resources/darkmode/dark.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/darkmode/dark.css b/src/main/resources/darkmode/dark.css index 3803a8bc..89922e46 100644 --- a/src/main/resources/darkmode/dark.css +++ b/src/main/resources/darkmode/dark.css @@ -7,8 +7,8 @@ --shadow-color: rgb(240 240 240 / 50%); --accent-color: rgb(0 0 240 / 50%); --owl-bg-pre: rgb(15 15 15); - --link: white; - --link-visited: gray; + --link: #DDC1F2; + --link-visited: #BD7DEE; --link-active: blue; --href-hover: gray; --bg-hlist: #67676E; From c683e1e3811f85fce1d69475dceae68f673f8a40 Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 6 Jan 2024 12:31:01 +0100 Subject: [PATCH 5/8] darkmode: added dark color for h tags --- src/main/resources/darkmode/dark.css | 1 + src/main/resources/darkmode/light.css | 1 + src/main/resources/lode/rec.css | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/darkmode/dark.css b/src/main/resources/darkmode/dark.css index 89922e46..2b1f1134 100644 --- a/src/main/resources/darkmode/dark.css +++ b/src/main/resources/darkmode/dark.css @@ -2,6 +2,7 @@ color-scheme: dark; --bg-status-box: rgb(0, 90, 156); --background-color: #3e3e42; + --htag-text: #83E9F0; --bg-backlink: #c1c1bd; --text-color: rgb(240 240 240); --shadow-color: rgb(240 240 240 / 50%); diff --git a/src/main/resources/darkmode/light.css b/src/main/resources/darkmode/light.css index e3a25aa1..2e429095 100644 --- a/src/main/resources/darkmode/light.css +++ b/src/main/resources/darkmode/light.css @@ -2,6 +2,7 @@ color-scheme: light; --bg-status-box: rgb(0, 90, 156); --background-color: white; + --htag-text: #005A9C; --bg-backlink: #F4FFFF; --text-color: rgb(15 15 15); --shadow-color: rgb(15 15 15 / 50%); diff --git a/src/main/resources/lode/rec.css b/src/main/resources/lode/rec.css index aeb4349b..dd541eb9 100644 --- a/src/main/resources/lode/rec.css +++ b/src/main/resources/lode/rec.css @@ -41,7 +41,7 @@ h3.list:before{counter-increment:subsection;content: counter(section) "." counte h3.list{margin-top: 20px; border-bottom: 0px; } /* background should be transparent, but WebTV has a bug */ -h1, h2, h3 { color: #005A9C; background: var(--background-color) } +h1, h2, h3 { color: var(--htag-text); background: var(--background-color) } h1 { font: 170% sans-serif } h2 { font: 140% sans-serif } h3 { font: 120% sans-serif } From 90e9bc0f71cc225a85a656ba239c4655452feb6b Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 6 Jan 2024 20:34:52 +0100 Subject: [PATCH 6/8] darkmode: improved color background and text for backlink --- src/main/resources/darkmode/dark.css | 3 ++- src/main/resources/darkmode/light.css | 1 + src/main/resources/lode/extra.css | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/darkmode/dark.css b/src/main/resources/darkmode/dark.css index 2b1f1134..6ed39312 100644 --- a/src/main/resources/darkmode/dark.css +++ b/src/main/resources/darkmode/dark.css @@ -3,7 +3,8 @@ --bg-status-box: rgb(0, 90, 156); --background-color: #3e3e42; --htag-text: #83E9F0; - --bg-backlink: #c1c1bd; + --bg-backlink: #6e6e67; + --text-backlink: white; --text-color: rgb(240 240 240); --shadow-color: rgb(240 240 240 / 50%); --accent-color: rgb(0 0 240 / 50%); diff --git a/src/main/resources/darkmode/light.css b/src/main/resources/darkmode/light.css index 2e429095..e1245061 100644 --- a/src/main/resources/darkmode/light.css +++ b/src/main/resources/darkmode/light.css @@ -4,6 +4,7 @@ --background-color: white; --htag-text: #005A9C; --bg-backlink: #F4FFFF; + --text-backlink: black; --text-color: rgb(15 15 15); --shadow-color: rgb(15 15 15 / 50%); --accent-color: rgb(240 0 0 / 50%); diff --git a/src/main/resources/lode/extra.css b/src/main/resources/lode/extra.css index d72be880..da1acefa 100644 --- a/src/main/resources/lode/extra.css +++ b/src/main/resources/lode/extra.css @@ -104,6 +104,7 @@ dt { padding: 2px; border: 1px dotted navy; background-color: var(--bg-backlink); + color: var(--text-backlink); } .imageblock { From ecf86f703b151d1dd7fc37c1a3444b5cb9c1a07b Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 6 Jan 2024 20:40:04 +0100 Subject: [PATCH 7/8] darkmode: reduced brightness of description box. --- src/main/resources/darkmode/dark.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/darkmode/dark.css b/src/main/resources/darkmode/dark.css index 6ed39312..7f44cece 100644 --- a/src/main/resources/darkmode/dark.css +++ b/src/main/resources/darkmode/dark.css @@ -14,7 +14,7 @@ --link-active: blue; --href-hover: gray; --bg-hlist: #67676E; - --bg-description:#67676E; + --bg-description: #535358; --literal:#49C00D; --type-ap: #EB4A4A; --type-op: #75E1FC; From ab46449f2ee5ec37346f19928f39ec814e621c14 Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 6 Jan 2024 23:49:32 +0100 Subject: [PATCH 8/8] darkmode: added white border and type-ni --- src/main/resources/darkmode/dark.css | 2 ++ src/main/resources/darkmode/light.css | 2 ++ src/main/resources/lode/extra.css | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/resources/darkmode/dark.css b/src/main/resources/darkmode/dark.css index 7f44cece..3a9bba6c 100644 --- a/src/main/resources/darkmode/dark.css +++ b/src/main/resources/darkmode/dark.css @@ -2,6 +2,7 @@ color-scheme: dark; --bg-status-box: rgb(0, 90, 156); --background-color: #3e3e42; + --border: white; --htag-text: #83E9F0; --bg-backlink: #6e6e67; --text-backlink: white; @@ -19,5 +20,6 @@ --type-ap: #EB4A4A; --type-op: #75E1FC; --type-dp: #75FA32; + --type-ni: #f3cdcd; } diff --git a/src/main/resources/darkmode/light.css b/src/main/resources/darkmode/light.css index e1245061..f4a54957 100644 --- a/src/main/resources/darkmode/light.css +++ b/src/main/resources/darkmode/light.css @@ -2,6 +2,7 @@ color-scheme: light; --bg-status-box: rgb(0, 90, 156); --background-color: white; + --border: navy; --htag-text: #005A9C; --bg-backlink: #F4FFFF; --text-backlink: black; @@ -19,4 +20,5 @@ --type-ap: maroon; --type-op: navy; --type-dp: green; + --type-ni: brown; } diff --git a/src/main/resources/lode/extra.css b/src/main/resources/lode/extra.css index da1acefa..2cc73565 100644 --- a/src/main/resources/lode/extra.css +++ b/src/main/resources/lode/extra.css @@ -7,7 +7,7 @@ h1 { } .hlist { - border: 1px solid navy; + border: 1px solid var(--border); padding:5px; background-color: var(--bg-hlist); } @@ -21,7 +21,7 @@ h1 { } .entity { - border: 1px solid navy; + border: 1px solid var(--border); margin:5px 0px 5px 0px; padding: 5px; } @@ -53,7 +53,7 @@ h1 { .type-ni { cursor:help; - color:brown; + color:var(--type-ni); } .logic { @@ -64,7 +64,7 @@ h1 { h3 { margin-top: 3px; padding-bottom: 5px; - border-bottom: 1px solid navy; + border-bottom: 1px solid var(--border); } h2 {