aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2025-03-31 13:22:21 -0400
committerPaul Duncan <pabs@pablotron.org>2025-03-31 13:22:21 -0400
commitc23c6db150a9dc6a93117598f5131ee9145ffe7e (patch)
tree913617cd0dc768648386e8c4061e52a989d076a3
parent3de5a77028dba37ae0f52e7d2307a99d61d74df0 (diff)
downloadpablotron.org-c23c6db150a9dc6a93117598f5131ee9145ffe7e.tar.xz
pablotron.org-c23c6db150a9dc6a93117598f5131ee9145ffe7e.zip
themes/hugo-pt2021/assets/script.js: only use light mode if explicitly selected by user
-rw-r--r--themes/hugo-pt2021/assets/script.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/themes/hugo-pt2021/assets/script.js b/themes/hugo-pt2021/assets/script.js
index 57e5a39..03b86c1 100644
--- a/themes/hugo-pt2021/assets/script.js
+++ b/themes/hugo-pt2021/assets/script.js
@@ -56,19 +56,19 @@ const D = document,
M = window.matchMedia,
on = (el, id, fn) => el.addEventListener(id, fn);
-// use theme if set, otherwise fall back to browser preference
+// use theme if set, otherwise fall back to dark mode
// FIXME: move to DOMContentLoaded?
//
// update (2025-03-31): prefer dark mode by default and only set light
-// mode if one of the following conditions is true:
-// 1. the user has explicitly set the theme using the navbar button, or
-// 2. the user has not explicitly set the theme but has indicated that
-// they prefer light mode.
+// mode if the user has explicitly selected the light theme using the
+// theme toggle.
+//
+// the old logic also attempted to account for "prefers-color-scheme:
+// light", but i want the default to be dark unless it is explicitly
+// overridden.
C.add('dark'); // unconditionally set dark mode
if (L && L.theme && L.theme === 'light') {
C.remove('dark'); // set light theme
-} else if ((!L || !L.theme) && M && M('(prefers-color-scheme: light)').matches) {
- C.remove('dark'); // set light theme
}
document.addEventListener('DOMContentLoaded', () => {