Update theme toggle mechanism
This commit is contained in:
parent
22687225b9
commit
246417a553
15 changed files with 425 additions and 200 deletions
|
|
@ -2,6 +2,17 @@
|
|||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<script>
|
||||
const setTheme = (theme) => {
|
||||
theme ??= localStorage.theme || "system";
|
||||
document.getElementById("themeLight").checked = theme === "light";
|
||||
document.getElementById("themeDark").checked = theme === "dark";
|
||||
localStorage.theme = theme;
|
||||
};
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
setTheme();
|
||||
});
|
||||
</script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="../assets/style/styleguide.css">
|
||||
|
|
@ -32,10 +43,18 @@
|
|||
<li><a href="../glow"><i data-icon="info"></i>Glow</a></li>
|
||||
<li class="active"><a href=""><i data-icon="info"></i>Demopage</a></li>
|
||||
<li><a href="../generator"><i data-icon="info"></i>Image Generator</a></li>
|
||||
<li class="dark-only toggleTheme" data-theme="light"><a href="#" aria-label="switch to light theme"><i
|
||||
data-icon="light" class="glow"></i></a></li>
|
||||
<li class="light-only toggleTheme" data-theme="dark"><a href="#" aria-label="switch to dark theme"><i
|
||||
data-icon="light" class="glow"></i></a></li>
|
||||
<li id="themeToggleDark" class="themeToggle">
|
||||
<input id="themeDark" type="checkbox" aria-label="Switch between dark and light mode">
|
||||
<label for="themeDark">
|
||||
<i data-icon="light"></i>
|
||||
</label>
|
||||
</li>
|
||||
<li id="themeToggleLight" class="themeToggle">
|
||||
<input id="themeLight" type="checkbox" aria-label="Switch between dark and light mode">
|
||||
<label for="themeLight">
|
||||
<i data-icon="light"></i>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<main>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue