Untitled
unknown
typescript
2 years ago
791 B
2
Indexable
// thunders/theme.ts import { thunder } from "killua"; type TTheme = 'system' | 'light' | 'dark'; const thunderTheme = thunder({ key: "theme", encrypt: false, default: 'system' as TTheme, expire: null, reducers: { system: () => { const theme = 'system' as TTheme; document.documentElement.dataset['theme'] = (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); return theme; }, light: () => { const theme = 'light' as TTheme; document.documentElement.dataset['theme'] = theme; return theme; }, dark: () => { const theme = 'dark' as TTheme; document.documentElement.dataset['theme'] = theme; return theme; }, }, }); export { thunderTheme };
Editor is loading...