Skip to content

Commit

Permalink
chore: store
Browse files Browse the repository at this point in the history
  • Loading branch information
guanbinrui committed Mar 6, 2024
1 parent 96ddea1 commit f49506f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lingui.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ const config = {
catalogs: [
{
path: 'src/locales/{locale}/messages',
include: ['src/app/**'],
include: [
'src/app/**',
'src/configs/**',
'src/components/**',
'src/constants/**',
'src/helpers/**',
'src/hooks/**',
'src/modals/**',
'src/store/**',
'src/services/**',
],
},
],
fallbackLocales: {
Expand Down
29 changes: 29 additions & 0 deletions src/store/useThemeModeStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';

import { createSelectors } from '@/helpers/createSelector.js';
import type { ThemeMode } from '@/types/index.js';

interface ThemeModeState {
themeMode: ThemeMode;
setThemeMode: (mode: ThemeMode) => void;
}

const useThemeModeStateBase = create<ThemeModeState, [['zustand/persist', unknown], ['zustand/immer', unknown]]>(
persist(
immer((set) => ({
themeMode: 'default',
setThemeMode: (mode) => {
set((state) => {
state.themeMode = mode;
});
},
})),
{
name: 'global-theme-state',
},
),
);

export const useThemeModeStore = createSelectors(useThemeModeStateBase);
2 changes: 1 addition & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Config } from 'tailwindcss';

const config: Config = {
content: [
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
Expand Down

0 comments on commit f49506f

Please sign in to comment.