Untitled
Anonymous
typescript
11/11/2023 2:22 PM
1.0 KB
26
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...