@dfinity/gix-components
Version:
A UI kit developed by the GIX team
20 lines (19 loc) • 637 B
JavaScript
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();