返回 presentation-ai
theme-panel-state.ts
根目录 / src / components / presentation / edit-panel / sections / theme / theme-panel-state.ts
1 import { create } from "zustand";
2
3 import { type CustomTheme } from "@/components/notebook/presentation/components/theme/types";
4 import { type ThemeProperties, type Themes } from "@/lib/presentation/themes";
5
6 type FilterOption = {
7 style: "all" | "minimal" | "professional" | "creative";
8 };
9
10 interface ThemeState {
11 tab: "standard" | "public";
12 theme: Themes;
13 setTab: (tab: "standard" | "public") => void;
14 setTheme: (theme: Themes) => void;
15 showFavorites: boolean;
16 setShowFavorites: (showFavorites: boolean) => void;
17 openCreateThemeModal: boolean;
18 setOpenCreateThemeModal: (openCreateThemeModal: boolean) => void;
19 themeFilterOption: FilterOption;
20 showFont: boolean;
21 setThemeFilterOption: (filter: FilterOption) => void;
22 setShowFont: (bool: boolean) => void;
23 openEditMenu: string | null;
24 setOpenEditMenu: (themeKey: string | null) => void;
25 editingTheme: CustomTheme | null;
26 setEditingTheme: (theme: CustomTheme | null) => void;
27 // Flag to indicate if we are customizing (creating new derived) vs editing
28 isCustomizing: boolean;
29 setIsCustomizing: (isCustomizing: boolean) => void;
30 // Theme data imported from a PPTX file
31 importedThemeData: ThemeProperties | null;
32 setImportedThemeData: (data: ThemeProperties | null) => void;
33 }
34
35 export const useThemePanelState = create<ThemeState>((set) => ({
36 tab: "standard",
37 setTab: (tab) => set({ tab }),
38 theme: "mystique",
39 setTheme: (theme) => set({ theme }),
40 showFavorites: false,
41 setShowFavorites: (showFavorites) => set({ showFavorites }),
42 openCreateThemeModal: false,
43 setOpenCreateThemeModal: (openCreateThemeModal) =>
44 set({ openCreateThemeModal }),
45 showFont: false,
46 themeFilterOption: {
47 style: "all",
48 },
49 setThemeFilterOption: (option) => set({ themeFilterOption: option }),
50 setShowFont: (bool) => set({ showFont: bool }),
51 openEditMenu: null,
52 setOpenEditMenu: (themeKey) => set({ openEditMenu: themeKey }),
53 editingTheme: null,
54 setEditingTheme: (theme) => set({ editingTheme: theme }),
55 isCustomizing: false,
56 setIsCustomizing: (isCustomizing) => set({ isCustomizing }),
57 importedThemeData: null,
58 setImportedThemeData: (data) => set({ importedThemeData: data }),
59 }));
60
60 lines TYPESCRIPT