mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor: move use-theme store to stores
This commit is contained in:
+1
-14
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
@@ -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}>
|
||||
|
||||
Reference in New Issue
Block a user