diff options
author | marudor <marudor@marudor.de> | 2019-05-16 15:22:47 +0200 |
---|---|---|
committer | marudor <marudor@marudor.de> | 2019-05-16 15:22:47 +0200 |
commit | 87e74ca90d4c13758461f380b00ed83b5a287da9 (patch) | |
tree | 545f0965a51987c9e61b3860f45a24b527bc1702 /public/static/js/theme.js | |
parent | 5c2388d3a2092505aff9f7b2e78e561c4db65385 (diff) |
Add color switcher to toolbar
Diffstat (limited to 'public/static/js/theme.js')
-rw-r--r-- | public/static/js/theme.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/public/static/js/theme.js b/public/static/js/theme.js new file mode 100644 index 0000000..71fb6ae --- /dev/null +++ b/public/static/js/theme.js @@ -0,0 +1,12 @@ +var validThemes = ['dark.min', 'light.min']; +var currentTheme = localStorage.getItem('theme'); +if (!validThemes.includes(currentTheme)) { + currentTheme = window.matchMedia('(prefers-color-scheme: dark').matches ? 'dark.min' : 'light.min'; +} +addStyleSheet(currentTheme, 'theme'); + +function toggleTheme() { + currentTheme = currentTheme === 'dark.min' ? 'light.min' : 'dark.min'; + localStorage.setItem('theme', currentTheme); + addStyleSheet(currentTheme, 'theme'); +} |