summaryrefslogtreecommitdiff
path: root/share/html_start
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-04-27 21:55:20 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-04-27 21:55:20 +0200
commitd09aaa6f0c33d4c22f383e93bf389e821f4c76c4 (patch)
tree2580dd4f4cf9804e47dda50f45d53be6b537bf7e /share/html_start
parent7a8d2dde13b51dbefd99b5c45e0294a6b7486d7f (diff)
add a bit of dark mode
Diffstat (limited to 'share/html_start')
-rw-r--r--share/html_start25
1 files changed, 25 insertions, 0 deletions
diff --git a/share/html_start b/share/html_start
index 0e21831..68be715 100644
--- a/share/html_start
+++ b/share/html_start
@@ -5,8 +5,33 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href=".data/css/main.css"/>
+ <link rel="stylesheet" type="text/css" href=".data/css/light.css" id="theme"/>
<!-- glightbox (C) biati digital, MIT licensed. <https://biati-digital.github.io/glightbox/> -->
<link rel="stylesheet" href=".data/css/glightbox.min.css" />
+ <script>
+ function addStyleSheet(name, id) {
+ var path = '.data/css/' + name + '.css';
+ var old = document.getElementById(id);
+ if (old && (old.href != path)) {
+ old.href = path;
+ }
+ }
+ var otherTheme = {
+ 'dark': 'light',
+ 'light': 'dark',
+ };
+ var currentTheme = localStorage.getItem('theme');
+ if (!otherTheme.hasOwnProperty(currentTheme)) {
+ currentTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
+ }
+ addStyleSheet(currentTheme, 'theme');
+
+ function toggleTheme() {
+ currentTheme = otherTheme[currentTheme] || 'light';
+ localStorage.setItem('theme', currentTheme);
+ addStyleSheet(currentTheme, 'theme');
+ }
+ </script>
<script src=".data/js/glightbox.min.js"></script>
</head>
<body><div>