summaryrefslogtreecommitdiff
path: root/templates/layouts/default.html.ep
diff options
context:
space:
mode:
Diffstat (limited to 'templates/layouts/default.html.ep')
-rw-r--r--templates/layouts/default.html.ep16
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>