diff options
| author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-27 19:53:04 -0600 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-27 19:53:04 -0600 |
| commit | b6e8e041096a921accd439db00c9171c0f68d91b (patch) | |
| tree | e4c58632b8956de12d249f99e0836138a6028655 /static/js/util | |
| parent | 68f3bd53328606a921dd72870f38723286d803e1 (diff) | |
| download | hatecomputers.club-b6e8e041096a921accd439db00c9171c0f68d91b.tar.gz hatecomputers.club-b6e8e041096a921accd439db00c9171c0f68d91b.zip | |
use media queries
Diffstat (limited to 'static/js/util')
| -rw-r--r-- | static/js/util/setThemeBeforeRender.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/static/js/util/setThemeBeforeRender.js b/static/js/util/setThemeBeforeRender.js index d826193..b8f299a 100644 --- a/static/js/util/setThemeBeforeRender.js +++ b/static/js/util/setThemeBeforeRender.js @@ -1,6 +1,8 @@ +const preferredMode = window.matchMedia("(prefers-color-scheme: dark)").matches + ? "DARK" + : "LIGHT"; +localStorage.setItem("theme", localStorage.getItem("theme") || preferredMode); + // sets theme before rendering & jquery loaded to prevent flashing of uninitialized theme // (ugly white background) -document.documentElement.setAttribute( - "data-theme", - localStorage.getItem("theme"), -); +document.documentElement.setAttribute("data-theme", preferredMode); |
