diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-08-21 11:08:40 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-08-21 11:08:40 +0200 |
commit | 73cbb842a4815a36e03d9e0c7243effd568c7bfd (patch) | |
tree | 0f02c939b17aee8e0fab5eb8e5daa6bb7683b2e2 /templates/header.html | |
parent | 6f1069470dac198edd3606d9e592312baaccd131 (diff) |
add proper dark mode support0.1.0
Diffstat (limited to 'templates/header.html')
-rw-r--r-- | templates/header.html | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/templates/header.html b/templates/header.html index b7260a5..1bf6219 100644 --- a/templates/header.html +++ b/templates/header.html @@ -11,3 +11,15 @@ <link rel="apple-touch-icon" sizes="152x152" href="/static/icons/icon-152x152.png"> <link rel="apple-touch-icon" sizes="167x167" href="/static/icons/icon-167x167.png"> <link href="/static/v0/css/light.min.css" id="theme" rel="stylesheet"> + +<script> + function addStyleSheet(name, id) { + const path = "/static/v0/css/" + name + ".min.css"; + const old = document.getElementById(id); + if (old && (old.href != path)) { + old.href = path; + } + } + const currentTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; + addStyleSheet(currentTheme, 'theme'); +</script> |