From be970248686c0af7d8506cba8c64bf507419da3d Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Sun, 22 Jun 2025 13:07:02 +0200 Subject: so much stuff??? --- apps/web/src/stores/timeline-store.ts | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 apps/web/src/stores/timeline-store.ts (limited to 'apps/web/src/stores/timeline-store.ts') diff --git a/apps/web/src/stores/timeline-store.ts b/apps/web/src/stores/timeline-store.ts new file mode 100644 index 00000000..66fb085c --- /dev/null +++ b/apps/web/src/stores/timeline-store.ts @@ -0,0 +1,61 @@ +import { create } from "zustand"; + +export interface TimelineClip { + id: string; + mediaId: string; + name: string; + duration: number; +} + +export interface TimelineTrack { + id: string; + name: string; + type: "video" | "audio" | "effects"; + clips: TimelineClip[]; +} + +interface TimelineStore { + tracks: TimelineTrack[]; + + // Actions + addTrack: (type: "video" | "audio" | "effects") => void; + removeTrack: (trackId: string) => void; + addClipToTrack: (trackId: string, clip: Omit) => void; +} + +export const useTimelineStore = create((set) => ({ + tracks: [], + + addTrack: (type) => { + const newTrack: TimelineTrack = { + id: crypto.randomUUID(), + name: `${type.charAt(0).toUpperCase() + type.slice(1)} Track`, + type, + clips: [], + }; + set((state) => ({ + tracks: [...state.tracks, newTrack], + })); + }, + + removeTrack: (trackId) => { + set((state) => ({ + tracks: state.tracks.filter((track) => track.id !== trackId), + })); + }, + + addClipToTrack: (trackId, clipData) => { + const newClip: TimelineClip = { + ...clipData, + id: crypto.randomUUID(), + }; + + set((state) => ({ + tracks: state.tracks.map((track) => + track.id === trackId + ? { ...track, clips: [...track.clips, newClip] } + : track + ), + })); + }, +})); -- cgit v1.3.1