remove theme store
This commit is contained in:
@@ -1,27 +0,0 @@
|
|||||||
import { writable } from 'svelte/store';
|
|
||||||
import type { Theme } from '$types';
|
|
||||||
|
|
||||||
const createThemeStore = () => {
|
|
||||||
let theme = localStorage.getItem('theme') as Theme | null;
|
|
||||||
if (!theme) {
|
|
||||||
theme = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
||||||
? 'dark'
|
|
||||||
: 'light';
|
|
||||||
localStorage.setItem('theme', theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { subscribe, update } = writable<Theme>(theme);
|
|
||||||
|
|
||||||
return {
|
|
||||||
subscribe,
|
|
||||||
toggleTheme: () => {
|
|
||||||
update(currentTheme => {
|
|
||||||
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
||||||
localStorage.setItem('theme', newTheme);
|
|
||||||
return newTheme;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const theme = createThemeStore();
|
|
Reference in New Issue
Block a user