Files
console/src/lib/stores/app.ts
T

20 lines
482 B
TypeScript

import { browser } from '$app/env';
import { writable } from 'svelte/store';
export type AppStore = {
theme: 'light' | 'dark' | 'auto';
themeInUse: 'light' | 'dark';
};
export const app = writable<AppStore>({
theme: 'auto',
themeInUse: 'light'
});
if (browser) {
app.update((n) => ({
...n,
...(JSON.parse(localStorage.getItem('appwrite')) ?? {})
}));
app.subscribe((u) => localStorage.setItem('appwrite', JSON.stringify(u) ?? '{}'));
}