diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 33ae268..b6cea57 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -15,7 +15,6 @@ {{ end }} - {{ block "footer" . }} @@ -23,5 +22,6 @@ src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> {{ end }} + diff --git a/static/css/style.css b/static/css/style.css index 3f99abd..4ad5b2c 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -103,7 +103,6 @@ weight: bold; #mode-selector { position: relative; display: flex; -padding: 0.125em 0.25em; border: 3px solid transparent; } #mode-selector button { diff --git a/static/js/dark.js b/static/js/dark.js index 2996ba7..74b53fc 100644 --- a/static/js/dark.js +++ b/static/js/dark.js @@ -286,19 +286,30 @@ function updateModeSelectorState() { /* Set specified color mode (auto, light, dark). */ +function setDark() { + document.body.classList.add('dark'); + document.getElementById("mode-selector").classList.add('dark'); +} +function unsetDark() { + document.body.classList.remove('dark'); + document.getElementById("mode-selector").classList.remove('dark'); +} function setMode(modeOption) { GWLog("setMode"); // Inject the appropriate styles. let modeStyles = document.querySelector("#mode-styles"); if (modeOption == 'auto') { - modeStyles.innerHTML = `@media (prefers-color-scheme:dark) {${GW.modeStyles}}`; + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + setDark(); + } else { + unsetDark(); + } + } else if (modeOption == 'dark') { - document.body.classList.add('dark'); - document.getElementById("mode-selector").classList.add('dark'); + setDark(); } else { - document.body.classList.remove('dark'); - document.getElementById("mode-selector").classList.remove('dark'); + unsetDark(); } // Update selector state.