diff options
| author | Maze <167211895+mazeincoding@users.noreply.github.com> | 2026-01-31 00:20:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-31 00:20:04 +0100 |
| commit | 7bf0984698e43b9aa2dd879f65951318ed410390 (patch) | |
| tree | ccf2cd590a47d550152afc07129cb55c71a9ec35 /apps/web/src/stores/editor-store.ts | |
| parent | 0173db99448d1c4c6415dcf15272e17551b48b04 (diff) | |
| download | opencut-7bf0984698e43b9aa2dd879f65951318ed410390.tar.gz | |
codebase overhaul (#697)
Diffstat (limited to 'apps/web/src/stores/editor-store.ts')
| -rw-r--r-- | apps/web/src/stores/editor-store.ts | 129 |
1 files changed, 54 insertions, 75 deletions
diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts index 9923aa87..5c4856d3 100644 --- a/apps/web/src/stores/editor-store.ts +++ b/apps/web/src/stores/editor-store.ts @@ -1,91 +1,70 @@ import { create } from "zustand"; import { persist } from "zustand/middleware"; -import { CanvasPreset } from "@/types/editor"; - -export type PlatformLayout = "tiktok"; - -export const PLATFORM_LAYOUTS: Record<PlatformLayout, string> = { - tiktok: "TikTok", -}; +import type { TPlatformLayout } from "@/types/editor"; +import { DEFAULT_CANVAS_PRESETS } from "@/constants/project-constants"; +import type { TCanvasSize } from "@/types/project"; interface LayoutGuideSettings { - platform: PlatformLayout | null; + platform: TPlatformLayout | null; } interface EditorState { - // Loading states - isInitializing: boolean; - isPanelsReady: boolean; - - // Editor UI settings - canvasPresets: CanvasPreset[]; - layoutGuide: LayoutGuideSettings; - - // Actions - setInitializing: (loading: boolean) => void; - setPanelsReady: (ready: boolean) => void; - initializeApp: () => Promise<void>; - setLayoutGuide: (settings: Partial<LayoutGuideSettings>) => void; - toggleLayoutGuide: (platform: PlatformLayout) => void; + isInitializing: boolean; + isPanelsReady: boolean; + canvasPresets: TCanvasSize[]; + layoutGuide: LayoutGuideSettings; + setInitializing: (loading: boolean) => void; + setPanelsReady: (ready: boolean) => void; + initializeApp: () => Promise<void>; + setLayoutGuide: (settings: Partial<LayoutGuideSettings>) => void; + toggleLayoutGuide: (platform: TPlatformLayout) => void; } -const DEFAULT_CANVAS_PRESETS: CanvasPreset[] = [ - { name: "16:9", width: 1920, height: 1080 }, - { name: "9:16", width: 1080, height: 1920 }, - { name: "1:1", width: 1080, height: 1080 }, - { name: "4:3", width: 1440, height: 1080 }, -]; - export const useEditorStore = create<EditorState>()( - persist( - (set) => ({ - // Initial states - isInitializing: true, - isPanelsReady: false, - canvasPresets: DEFAULT_CANVAS_PRESETS, - layoutGuide: { - platform: null, - }, - - // Actions - setInitializing: (loading) => { - set({ isInitializing: loading }); - }, + persist( + (set) => ({ + isInitializing: true, + isPanelsReady: false, + canvasPresets: DEFAULT_CANVAS_PRESETS, + layoutGuide: { + platform: null, + }, + setInitializing: (loading) => { + set({ isInitializing: loading }); + }, - setPanelsReady: (ready) => { - set({ isPanelsReady: ready }); - }, + setPanelsReady: (ready) => { + set({ isPanelsReady: ready }); + }, - initializeApp: async () => { - console.log("Initializing video editor..."); - set({ isInitializing: true, isPanelsReady: false }); + initializeApp: async () => { + set({ isInitializing: true, isPanelsReady: false }); - set({ isPanelsReady: true, isInitializing: false }); - console.log("Video editor ready"); - }, + set({ isPanelsReady: true, isInitializing: false }); + }, - setLayoutGuide: (settings) => { - set((state) => ({ - layoutGuide: { - ...state.layoutGuide, - ...settings, - }, - })); - }, + setLayoutGuide: (settings) => { + set((state) => ({ + layoutGuide: { + ...state.layoutGuide, + ...settings, + }, + })); + }, - toggleLayoutGuide: (platform) => { - set((state) => ({ - layoutGuide: { - platform: state.layoutGuide.platform === platform ? null : platform, - }, - })); - }, - }), - { - name: "editor-settings", - partialize: (state) => ({ - layoutGuide: state.layoutGuide, - }), - } - ) + toggleLayoutGuide: (platform) => { + set((state) => ({ + layoutGuide: { + platform: state.layoutGuide.platform === platform ? null : platform, + }, + })); + }, + }), + { + name: "editor-settings", + partialize: (state) => ({ + layoutGuide: state.layoutGuide, + }), + }, + ), ); |
