Chrysoblog/src/lib/theme.ts

14 lines
321 B
TypeScript

import { writable } from 'svelte/store'
import { browser } from "$app/environment"
type Theme = 'tokiwa' | 'star'
const userTheme = browser && localStorage.getItem('color-scheme')
export const theme = writable(userTheme ?? 'tokiwa')
// set the theme
export function setTheme(newTheme: Theme) {
theme.set(newTheme)
}