Browse Source

Toggle theme with `<html class="dark">`

This allows to:
* Still default to `prefers-color-scheme`.
* Set theme with a button when implemented.
Script is inside `head` to avoid FOUC.
pull/178/head
Anton Grouchtchak 3 years ago
parent
commit
c530fffdc8
No known key found for this signature in database GPG Key ID: 17F776B7A59A0AEA
  1. 2
      src/www/css/vendor/tailwind.min.css
  2. 7
      src/www/index.html

2
src/www/css/vendor/tailwind.min.css

File diff suppressed because one or more lines are too long

7
src/www/index.html

@ -9,6 +9,13 @@
<link rel="apple-touch-icon" href="./img/apple-touch-icon.png"> <link rel="apple-touch-icon" href="./img/apple-touch-icon.png">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<script>
if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
</script>
</head> </head>
<style> <style>

Loading…
Cancel
Save