/** * Theme Switcher Utility */ // Theme configuration const THEMES = ['crimson', 'dark', 'light']; const THEME_ICONS = { crimson: ``, dark: ``, light: ``, }; const THEME_LABELS = { crimson: 'Switch to dark mode', dark: 'Switch to light mode', light: 'Switch to crimson theme', }; let currentTheme = localStorage.getItem('an-theme') || 'crimson'; function applyTheme(theme) { document.documentElement.setAttribute('data-theme', theme); document.querySelectorAll('.theme-toggle').forEach(btn => { btn.innerHTML = THEME_ICONS[theme]; btn.setAttribute('title', THEME_LABELS[theme]); btn.setAttribute('aria-label', THEME_LABELS[theme]); }); localStorage.setItem('an-theme', theme); currentTheme = theme; } function nextTheme() { const idx = THEMES.indexOf(currentTheme); return THEMES[(idx + 1) % THEMES.length]; } // Export for use in other files window.ThemeUtils = { THEMES, applyTheme, nextTheme, getCurrentTheme: () => currentTheme, };