diff options
author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-01-12 23:09:34 -0800 |
---|---|---|
committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-01-12 23:09:34 -0800 |
commit | 18a945aab9b3129b82076f633fab1d13ba28148e (patch) | |
tree | 09703cdc24992c42c5c14051e73e0b614280f5bd /static/js/util | |
download | phoneassistant-18a945aab9b3129b82076f633fab1d13ba28148e.tar.gz phoneassistant-18a945aab9b3129b82076f633fab1d13ba28148e.zip |
initial commit by simponic-infra
Diffstat (limited to 'static/js/util')
-rw-r--r-- | static/js/util/setThemeBeforeRender.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/static/js/util/setThemeBeforeRender.js b/static/js/util/setThemeBeforeRender.js new file mode 100644 index 0000000..b025cce --- /dev/null +++ b/static/js/util/setThemeBeforeRender.js @@ -0,0 +1,11 @@ +const preferredMode = window.matchMedia("(prefers-color-scheme: dark)").matches + ? "DARK" + : "LIGHT"; + +// sets theme before rendering & jquery loaded to prevent flashing of uninitialized theme +// (ugly white background) +localStorage.setItem("theme", localStorage.getItem("theme") || preferredMode); +document.documentElement.setAttribute( + "data-theme", + localStorage.getItem("theme"), +); |