gabriel / musehub public
theme.ts typescript
23 lines 707 B
Raw
sha256:e519738f2102d625d47828a17d113283cd744577b43551013cb668fd04f1c3fe chore(mwp8/phase5): tick all RG checkboxes; close-out doc (… Sonnet 4.6 18 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 2 commits
sha256:e519738f2102d625d47828a17d113283cd744577b43551013cb668fd04f1c3fe chore(mwp8/phase5): tick all RG checkboxes; close-out doc (… Sonnet 4.6 18 days ago
sha256:0e5174da777684df43b2db71f282079030ef28bacffb93e19c29ee712b2a8bc4 test(mwp8/phase0): audit — repair+force-push leave stale ca… Sonnet 4.6 20 days ago