diff options
author | marudor <marudor@marudor.de> | 2019-05-16 16:10:53 +0200 |
---|---|---|
committer | marudor <marudor@marudor.de> | 2019-05-16 16:10:53 +0200 |
commit | 84b32b28e9f1da6576e4864a0f374b341a2c9920 (patch) | |
tree | d6bd27263aa3117c9368d3005fe27519f4793247 /templates/layouts/default.html.ep | |
parent | 87e74ca90d4c13758461f380b00ed83b5a287da9 (diff) |
Further color improvements
Diffstat (limited to 'templates/layouts/default.html.ep')
-rw-r--r-- | templates/layouts/default.html.ep | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 54f9e1f..a512314 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -32,8 +32,22 @@ document.head.appendChild(st); } } + var otherTheme = { + 'dark.min': 'light.min', + 'light.min': 'dark.min', +}; +var currentTheme = localStorage.getItem('theme'); +if (!otherTheme.hasOwnProperty(currentTheme)) { + currentTheme = window.matchMedia('(prefers-color-scheme: dark').matches ? 'dark.min' : 'light.min'; +} +addStyleSheet(currentTheme, 'theme'); + +function toggleTheme() { + currentTheme = otherTheme[currentTheme] || 'light.min'; + localStorage.setItem('theme', currentTheme); + addStyleSheet(currentTheme, 'theme'); +} </script> - %= javascript "/static/${av}/js/theme.min.js" <noscript> %= stylesheet "/static/${av}/css/light.min.css" </noscript> |