forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuiStore.js
More file actions
34 lines (28 loc) · 1.05 KB
/
Copy pathuiStore.js
File metadata and controls
34 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { create } from 'zustand';
import { devtools } from 'zustand/middleware';
/**
* uiStore controls UI state (modals, loaders, theme, etc.).
* Requirements: Consistent state across the application.
*/
export const useUIStore = create(
devtools(
(set) => ({
isSidebarOpen: true,
theme: 'dark', // Default to dark mode
activeModal: null, // modal name or ID
isLoading: false,
/** Toggles the sidebar visibility. */
toggleSidebar: () =>
set((state) => ({ isSidebarOpen: !state.isSidebarOpen }), false, 'ui/toggleSidebar'),
/** Sets the global theme. */
setTheme: (theme) => set({ theme }, false, 'ui/setTheme'),
/** Opens a specific modal. */
openModal: (modalId) => set({ activeModal: modalId }, false, 'ui/openModal'),
/** Closes the current modal. */
closeModal: () => set({ activeModal: null }, false, 'ui/closeModal'),
/** Updates global loading state. */
setLoading: (isLoading) => set({ isLoading }, false, 'ui/setLoading'),
}),
{ name: 'UIStore' }
)
);