adds dark mode

This commit is contained in:
Drew committed 2025-04-26 14:57:47 -06:00
1 parent e0546c0e2e
commit bd702f8f51
11 files changed
+87 -24

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
// Set initial theme on page load
(function() {
const isDark = localStorage.theme === "dark" ||
(!("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches);
document.documentElement.classList.toggle("dark", isDark);
// Update label on load
const label = document.getElementById("darkmode-label");
if (label) label.textContent = !isDark ? "Dark" : "Light";
})();
// Toggle dark mode and update label/localStorage
function toggleDarkMode() {
const html = document.documentElement;
const isDark = html.classList.toggle("dark");
localStorage.theme = isDark ? "dark" : "light";
const label = document.getElementById("darkmode-label");
if (label) label.textContent = !isDark ? "Dark" : "Light";
}