refactor: move use-theme store to stores

This commit is contained in:
Tom (plebeius.eth)
2024-05-31 20:14:32 +02:00
parent 8a47c0d69b
commit 911ec8f65f
3 changed files with 18 additions and 15 deletions
+1 -14
View File
@@ -1,17 +1,4 @@
import { create, StoreApi } from 'zustand';
interface ThemeState {
theme: string;
setTheme: (theme: string) => void;
}
const useThemeStore = create<ThemeState>((set: StoreApi<ThemeState>['setState']) => ({
theme: localStorage.getItem('theme') || 'yotsuba',
setTheme: (theme: string) => {
localStorage.setItem('theme', theme);
set({ theme });
},
}));
import useThemeStore from '../stores/use-theme-store';
const useTheme = (): [string, (theme: string) => void] => {
const { theme, setTheme } = useThemeStore();