diff options
| author | Maze Winther <mazewinther@gmail.com> | 2025-08-04 17:17:48 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2025-08-04 17:17:48 +0200 |
| commit | 9ec5a022520aa3a2d1e18b4e3b4056f2ff5dcd35 (patch) | |
| tree | 3fb53ec6ca8ead167aed3ba69c5f8b0dfd40b6ef /apps/web/src/stores/editor-store.ts | |
| parent | 0386624ff5fd6d82d64d6b103ddc1a7e5045f45b (diff) | |
| download | opencut-9ec5a022520aa3a2d1e18b4e3b4056f2ff5dcd35.tar.gz | |
feat: layout guide for tiktok
Diffstat (limited to 'apps/web/src/stores/editor-store.ts')
| -rw-r--r-- | apps/web/src/stores/editor-store.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts index aac7077e..a9c8f2ca 100644 --- a/apps/web/src/stores/editor-store.ts +++ b/apps/web/src/stores/editor-store.ts @@ -2,6 +2,15 @@ import { create } from "zustand"; import { CanvasSize, CanvasPreset } from "@/types/editor"; type CanvasMode = "preset" | "original" | "custom"; +export type PlatformLayout = "tiktok"; + +export const PLATFORM_LAYOUTS: Record<PlatformLayout, string> = { + tiktok: "TikTok", +}; + +interface LayoutGuideSettings { + platform: PlatformLayout | null; +} interface EditorState { // Loading states @@ -12,6 +21,7 @@ interface EditorState { canvasSize: CanvasSize; canvasMode: CanvasMode; canvasPresets: CanvasPreset[]; + layoutGuide: LayoutGuideSettings; // Actions setInitializing: (loading: boolean) => void; @@ -20,6 +30,8 @@ interface EditorState { setCanvasSize: (size: CanvasSize) => void; setCanvasSizeToOriginal: (aspectRatio: number) => void; setCanvasSizeFromAspectRatio: (aspectRatio: number) => void; + setLayoutGuide: (settings: Partial<LayoutGuideSettings>) => void; + toggleLayoutGuide: (platform: PlatformLayout) => void; } const DEFAULT_CANVAS_PRESETS: CanvasPreset[] = [ @@ -70,6 +82,9 @@ export const useEditorStore = create<EditorState>((set, get) => ({ canvasSize: { width: 1920, height: 1080 }, // Default 16:9 HD canvasMode: "preset" as CanvasMode, canvasPresets: DEFAULT_CANVAS_PRESETS, + layoutGuide: { + platform: null, + }, // Actions setInitializing: (loading) => { @@ -101,4 +116,21 @@ export const useEditorStore = create<EditorState>((set, get) => ({ const newCanvasSize = findBestCanvasPreset(aspectRatio); set({ canvasSize: newCanvasSize, canvasMode: "custom" }); }, + + setLayoutGuide: (settings) => { + set((state) => ({ + layoutGuide: { + ...state.layoutGuide, + ...settings, + }, + })); + }, + + toggleLayoutGuide: (platform) => { + set((state) => ({ + layoutGuide: { + platform: state.layoutGuide.platform === platform ? null : platform, + }, + })); + }, })); |
