From 051b32a983c0a26881793d5d80976521e642c668 Mon Sep 17 00:00:00 2001 From: Lewis Dale Date: Fri, 1 Mar 2024 08:16:23 +0000 Subject: [PATCH] Enable resetting the colour scheme to the system appearance --- src/_includes/base.njk | 12 ++++++------ src/css/exceptions/color-scheme-picker.css | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/_includes/base.njk b/src/_includes/base.njk index 8dfb980..8e23f18 100644 --- a/src/_includes/base.njk +++ b/src/_includes/base.njk @@ -67,6 +67,10 @@ Light + {{ content | safe }} @@ -90,11 +94,7 @@ return localStorage.getItem('color-scheme'); } - if (window.matchMedia('(prefers-color-scheme: dark)')?.matches) { - return "dark"; - } - - return "light"; + return "system"; }; const data = new Proxy({ @@ -110,7 +110,7 @@ }); const onRadioChange = e => { - data[e.target.name] = e.target.value; + data[e.target.name] = e.target.value; } document.querySelectorAll('[name="color-scheme"]').forEach(radio => { diff --git a/src/css/exceptions/color-scheme-picker.css b/src/css/exceptions/color-scheme-picker.css index bad8631..e110bbb 100644 --- a/src/css/exceptions/color-scheme-picker.css +++ b/src/css/exceptions/color-scheme-picker.css @@ -59,6 +59,12 @@ header > * { } } + &:has([value="system"]) { + &::before { + content: "\f390"; + } + } + &:has(:checked)::before { text-shadow: var(--color-decoration) 1px 0 10px; }