UNPKG

@dfinity/gix-components

Version:
20 lines (19 loc) 637 B
import { applyTheme, getThemeFromSystemSettings, initTheme, resetTheme, } from "../utils/theme.utils"; import { writable } from "svelte/store"; export const initThemeStore = () => { const initialTheme = initTheme(); const { subscribe, set } = writable(initialTheme); return { subscribe, select: (theme) => { applyTheme({ theme, preserve: true }); set(theme); }, resetToSystemSettings: () => { const theme = getThemeFromSystemSettings(); resetTheme(theme); set(theme); }, }; }; export const themeStore = initThemeStore();