theme.ts
typescript
sha256:c04414e7e3b812ff02f351d9792c79837b7841133a864f98fcaeff53a2a4afad
feat(KD-6b): MuseHub vault UI per frozen §KD-6a
Human
minor
⚠ breaking
13 days ago
| 1 | const STORAGE_KEY = 'musehub-theme'; |
| 2 | |
| 3 | export function applyStoredTheme(): void { |
| 4 | if (localStorage.getItem(STORAGE_KEY) === 'light') { |
| 5 | document.documentElement.dataset['theme'] = 'light'; |
| 6 | } |
| 7 | } |
| 8 | |
| 9 | export function toggleTheme(): void { |
| 10 | const isLight = document.documentElement.dataset['theme'] === 'light'; |
| 11 | if (isLight) { |
| 12 | delete document.documentElement.dataset['theme']; |
| 13 | localStorage.setItem(STORAGE_KEY, 'dark'); |
| 14 | } else { |
| 15 | document.documentElement.dataset['theme'] = 'light'; |
| 16 | localStorage.setItem(STORAGE_KEY, 'light'); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | export function initThemeBtn(): void { |
| 21 | const btn = document.getElementById('navbar-theme-btn'); |
| 22 | if (btn) btn.addEventListener('click', toggleTheme); |
| 23 | } |
File History
1 commit
sha256:c04414e7e3b812ff02f351d9792c79837b7841133a864f98fcaeff53a2a4afad
feat(KD-6b): MuseHub vault UI per frozen §KD-6a
Human
minor
⚠
13 days ago