Add dark theme
Builds / ExectOS WebSite (push) Successful in 33s

This commit is contained in:
2026-11-29 21:04:43 +01:00
parent 0680c332aa
commit 5e5d203966
3 changed files with 259 additions and 33 deletions
@@ -15,5 +15,33 @@
{{ end }}
{{ end }}
</ul>
<button type="button" id="theme-toggle" class="theme-toggle" aria-label="Switch to dark theme" title="Switch to dark theme">
<svg class="theme-toggle-track-icon sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/></svg>
<svg class="theme-toggle-track-icon moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
<span class="theme-toggle-thumb">
<svg class="sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/></svg>
<svg class="moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
</span>
</button>
</div>
</div>
<script>
(function() {
var root = document.documentElement;
var button = document.getElementById("theme-toggle");
function update() {
var label = root.getAttribute("data-theme") === "dark" ? "Switch to light theme" : "Switch to dark theme";
button.setAttribute("aria-label", label);
button.setAttribute("title", label);
}
button.addEventListener("click", function() {
var theme = root.getAttribute("data-theme") === "dark" ? "light" : "dark";
root.setAttribute("data-theme", theme);
try {
localStorage.setItem("exectos-theme", theme);
} catch (e) {}
update();
});
update();
})();
</script>