Files
FireworksApp/staticfiles/vite/assets/theme-DXAi27ON.js
T

2 lines
1.6 KiB
JavaScript

const r="sound-signal-theme",s=new Set(["dark","light"]);function c(){try{const e=window.localStorage.getItem(r);return s.has(e)?e:"dark"}catch{return"dark"}}function d(e,t){if(document.documentElement.dataset.theme=e,!t)return;const n=e==="dark"?"light":"dark",a=window.BOOMCAST_I18N||{};t.textContent=n==="light"?"☀ "+(a.lightMode||"Light mode"):"☾ "+(a.darkMode||"Dark mode"),t.setAttribute("aria-label",n==="light"?a.switchToLight||"Switch to light mode":a.switchToDark||"Switch to dark mode"),t.setAttribute("aria-pressed",String(e==="light"))}function o(){const e=document.querySelector(".theme-toggle")??document.createElement("button");e.isConnected||(e.className="theme-toggle",e.type="button",document.body.append(e)),d(c(),e),e.addEventListener("click",()=>{const t=document.documentElement.dataset.theme==="dark"?"light":"dark";try{window.localStorage.setItem(r,t)}catch{}d(t,e)})}function i(){const e=document.querySelector(".fireworks-menu-toggle");if(!e)return;const t=()=>{e.setAttribute("aria-expanded","false"),e.setAttribute("aria-label",e.dataset.openLabel)};e.addEventListener("click",()=>{const n=e.getAttribute("aria-expanded")!=="true";e.setAttribute("aria-expanded",String(n)),e.setAttribute("aria-label",n?e.dataset.closeLabel:e.dataset.openLabel)}),document.addEventListener("keydown",n=>{n.key==="Escape"&&e.getAttribute("aria-expanded")==="true"&&(t(),e.focus())}),window.matchMedia("(min-width: 44.001rem)").addEventListener("change",t)}d(c());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{o(),i()},{once:!0}):(o(),i());