added light/dark mode toggle v1, unified menu

This commit is contained in:
Joren de Graaf
2026-10-01 17:14:19 +02:00
parent 8f838715dd
commit 7d538b774d
102 changed files with 1870 additions and 1365 deletions
@@ -0,0 +1 @@
const d="sound-signal-theme",c=new Set(["dark","light"]);function r(){try{const e=window.localStorage.getItem(d);return c.has(e)?e:"dark"}catch{return"dark"}}function n(e,t){if(document.documentElement.dataset.theme=e,!t)return;const a=e==="dark"?"light":"dark";t.textContent=a==="light"?"☀ Light mode":"☾ Dark mode",t.setAttribute("aria-label","Switch to "+a+" mode"),t.setAttribute("aria-pressed",String(e==="light"))}function o(){const e=document.createElement("button");e.className="theme-toggle",e.type="button",document.body.append(e),n(r(),e),e.addEventListener("click",()=>{const t=document.documentElement.dataset.theme==="dark"?"light":"dark";try{window.localStorage.setItem(d,t)}catch{}n(t,e)})}n(r());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o,{once:!0}):o();