Initial commit

This commit is contained in:
Yaojia Wang
2025-11-03 00:04:07 +01:00
parent 34b701de48
commit 097300e8ec
37 changed files with 3473 additions and 109 deletions

67
stores/ui-store.ts Normal file
View File

@@ -0,0 +1,67 @@
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
interface Notification {
id: string;
title: string;
message: string;
type: 'success' | 'error' | 'warning' | 'info';
}
interface UIState {
// Sidebar
sidebarOpen: boolean;
toggleSidebar: () => void;
setSidebarOpen: (open: boolean) => void;
// Theme
theme: 'light' | 'dark' | 'system';
setTheme: (theme: 'light' | 'dark' | 'system') => void;
// Modals
openModal: string | null;
setOpenModal: (modal: string | null) => void;
// Notifications
notifications: Notification[];
addNotification: (notification: Omit<Notification, 'id'>) => void;
removeNotification: (id: string) => void;
}
export const useUIStore = create<UIState>()(
devtools(
persist(
(set) => ({
sidebarOpen: true,
toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
setSidebarOpen: (open) => set({ sidebarOpen: open }),
theme: 'system',
setTheme: (theme) => set({ theme }),
openModal: null,
setOpenModal: (modal) => set({ openModal: modal }),
notifications: [],
addNotification: (notification) =>
set((state) => ({
notifications: [
...state.notifications,
{ ...notification, id: crypto.randomUUID() },
],
})),
removeNotification: (id) =>
set((state) => ({
notifications: state.notifications.filter((n) => n.id !== id),
})),
}),
{
name: 'colaflow-ui-storage',
partialize: (state) => ({
sidebarOpen: state.sidebarOpen,
theme: state.theme
}),
}
)
)
);