diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-06-05 21:50:26 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-06-05 21:50:26 +0200 |
| commit | 44a95927edb532f8982cf24c03d9fdd129016bd6 (patch) | |
| tree | cd0efffc182f9429f8ec2bfe9622e6d36446f112 /apps/projects | |
| parent | 54b63daf1b5cefb54a3c616a4fee3ef57a671936 (diff) | |
| download | greatoffice-44a95927edb532f8982cf24c03d9fdd129016bd6.tar.xz greatoffice-44a95927edb532f8982cf24c03d9fdd129016bd6.zip | |
feat: Implement new theme switcher component and backend
The theme is now shared between the domain returned by base_domain()
Diffstat (limited to 'apps/projects')
| -rw-r--r-- | apps/projects/src/index.html | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/apps/projects/src/index.html b/apps/projects/src/index.html index 985b62b..22dba4f 100644 --- a/apps/projects/src/index.html +++ b/apps/projects/src/index.html @@ -26,11 +26,18 @@ <link rel="icon" href="./_assets/pwa/favicon.svg"> <script> - const currentTheme = localStorage.getItem("theme"); + const value = `; ${document.cookie}`; + const parts = value.split(`; go_theme=`); + let currentTheme = "system"; + if (parts.length === 2) { + currentTheme = parts.pop().split(";").shift(); + } if (currentTheme === "light") { document.querySelector("html").dataset.theme = "light"; - } else { + } else if (currentTheme === "dark") { document.querySelector("html").dataset.theme = "dark"; + } else { + document.querySelector("html").dataset.theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } </script> <link rel="stylesheet" |
