updating dark academia stylings
All checks were successful
Build Org Website / build (push) Successful in 44s

This commit is contained in:
2026-05-09 18:08:58 +01:00
parent e2e4f1467f
commit bd368b5ccd
7 changed files with 150 additions and 14 deletions

View File

@@ -77,19 +77,32 @@ document.addEventListener("DOMContentLoaded", () => {
(function(){
const root = document.documentElement;
const storageKey = "theme";
const themes = ["light", "dark", "dark-academia"];
const labels = {
"light": "Light",
"dark": "Dark",
"dark-academia": "Academia"
};
const saved = localStorage.getItem(storageKey);
if (saved === "dark" || saved === "light") {
if (themes.includes(saved)) {
root.setAttribute("data-theme", saved);
}
const btn = document.getElementById("theme-toggle");
if (!btn) return;
const updateButton = () => {
const current = root.getAttribute("data-theme");
const label = labels[current] || "Auto";
btn.textContent = `Theme: ${label}`;
btn.setAttribute("aria-label", `Current theme: ${label}. Switch theme.`);
};
updateButton();
btn.addEventListener("click", () => {
const current = root.getAttribute("data-theme");
const next = current === "dark" ? "light" : "dark";
// If no current (auto), assume were toggling to dark first
const target = current ? next : "dark";
const index = themes.indexOf(current);
const target = themes[index === -1 ? 1 : (index + 1) % themes.length];
root.setAttribute("data-theme", target);
localStorage.setItem(storageKey, target);
updateButton();
});
})();