Files
OpenCut/apps/web/src/stores/assets-panel-store.ts
T

98 lines
1.9 KiB
TypeScript
Raw Normal View History

2025-11-26 08:47:03 +01:00
import {
CaptionsIcon,
ArrowLeftRightIcon,
SparklesIcon,
StickerIcon,
MusicIcon,
VideoIcon,
BlendIcon,
SlidersHorizontalIcon,
LucideIcon,
TypeIcon,
SettingsIcon,
} from "lucide-react";
import { create } from "zustand";
2026-01-21 00:59:03 +01:00
export const TAB_KEYS = [
"media",
"sounds",
"text",
"stickers",
"effects",
"transitions",
"captions",
"filters",
"adjustment",
"settings",
] as const;
2025-11-26 08:47:03 +01:00
2026-01-21 00:59:03 +01:00
export type Tab = (typeof TAB_KEYS)[number];
export const tabs = {
2025-11-26 08:47:03 +01:00
media: {
icon: VideoIcon,
label: "Media",
},
sounds: {
icon: MusicIcon,
label: "Sounds",
},
text: {
icon: TypeIcon,
label: "Text",
},
stickers: {
icon: StickerIcon,
label: "Stickers",
},
effects: {
icon: SparklesIcon,
label: "Effects",
},
transitions: {
icon: ArrowLeftRightIcon,
label: "Transitions",
},
captions: {
icon: CaptionsIcon,
label: "Captions",
},
filters: {
icon: BlendIcon,
label: "Filters",
},
adjustment: {
icon: SlidersHorizontalIcon,
label: "Adjustment",
},
settings: {
icon: SettingsIcon,
label: "Settings",
},
2026-01-21 00:59:03 +01:00
} satisfies Record<Tab, { icon: LucideIcon; label: string }>;
2025-11-26 08:47:03 +01:00
2026-01-20 22:14:49 +01:00
type MediaViewMode = "grid" | "list";
2025-12-25 21:15:36 +01:00
interface AssetsPanelStore {
2025-11-26 08:47:03 +01:00
activeTab: Tab;
setActiveTab: (tab: Tab) => void;
highlightMediaId: string | null;
requestRevealMedia: (mediaId: string) => void;
clearHighlight: () => void;
2026-01-20 22:14:49 +01:00
/* Media */
mediaViewMode: MediaViewMode;
setMediaViewMode: (mode: MediaViewMode) => void;
2025-11-26 08:47:03 +01:00
}
2025-12-25 21:15:36 +01:00
export const useAssetsPanelStore = create<AssetsPanelStore>((set) => ({
2025-11-26 08:47:03 +01:00
activeTab: "media",
setActiveTab: (tab) => set({ activeTab: tab }),
highlightMediaId: null,
requestRevealMedia: (mediaId) =>
set({ activeTab: "media", highlightMediaId: mediaId }),
clearHighlight: () => set({ highlightMediaId: null }),
2026-01-20 22:14:49 +01:00
mediaViewMode: "grid",
setMediaViewMode: (mode) => set({ mediaViewMode: mode }),
2025-11-26 08:47:03 +01:00
}));