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();
+16
View File
@@ -0,0 +1,16 @@
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 });
},
}));
export default useThemeStore;
+1 -1
View File
@@ -161,7 +161,7 @@ const Catalog = () => {
if (isInAllView) documentTitle = t('all');
else if (isInSubscriptionsView) documentTitle = t('subscriptions');
document.title = documentTitle + ` - ${t('catalog')}`;
}, [title, shortAddress]);
}, [title, shortAddress, isInAllView, isInSubscriptionsView, t]);
return (
<div className={styles.content}>