Add support for dark theme

Fixes #33.
This commit is contained in:
Florine W. Dekker 2022-11-26 14:34:01 +01:00
parent 6c8215bc0c
commit 9220ac6224
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
5 changed files with 24 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@fwdekker/template",
"version": "3.3.10",
"version": "3.4.0",
"description": "The base template for pages on fwdekker.com.",
"author": "Florine W. Dekker",
"license": "MIT",

View File

@ -1,5 +1,6 @@
/* pico.css overrides, based on https://picocss.com/docs/customization.html */
:root {
.fwd-nav,
:root[data-theme="light"] {
--primary: rgb(0, 51, 204) !important;
--primary-hover: rgb(0, 61, 245) !important;
--primary-focus: rgba(0, 41, 163, 0.125) !important;
@ -12,3 +13,16 @@
--switch-color: var(--primary-inverse) !important;
--switch-checked-background-color: var(--primary) !important;
}
:root[data-theme="dark"]:not(.fwd-nav) {
--primary: #1e88e5 !important;
--primary-hover: #2196f3 !important;
--primary-focus: rgba(30, 136, 229, 0.25) !important;
--primary-focus-opaque: rgb(30, 136, 229) !important;
--primary-inverse: white !important;
--form-element-active-border-color: var(--primary) !important;
--form-element-focus-color: var(--primary-focus) !important;
--switch-color: var(--primary-inverse) !important;
--switch-checked-background-color: var(--primary) !important;
}

View File

@ -75,7 +75,7 @@ noscript.fwd-js-notice p {
/* Header */
header.fwd-header a[href="."] {
color: black;
color: unset;
}

View File

@ -1,9 +1,16 @@
/* pico.css: Improved text contrast (see also picocss/pico#276) */
:root {
--code-color: var(--color) !important;
}
:root[data-theme="light"] {
--muted-color: hsl(205deg, 15%, 41%) !important;
}
:root[data-theme="dark"] {
--muted-color: hsl(205deg, 12%, 59%) !important;
}
/* pico.css: Bold labels, except for checkbox/radio labels */
:root {
--form-label-font-weight: bold;

View File

@ -243,9 +243,6 @@ function footerLink(prefix: string, text: string | null | undefined, url: string
* not a valid value as a parameter for that function, its value is considered `undefined`.
*/
doAfterLoad(() => {
const html = $("html")!;
if (html.dataset["theme"] == null) html.dataset["theme"] = "light";
const navTarget = $(getMetaProperty("fwd:nav:target"));
if (navTarget != null) {
navTarget.parentElement?.replaceChild(