summaryrefslogtreecommitdiff
path: root/apps/web/src/stores/timeline-store.ts
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-06-22 13:07:02 +0200
committerMaze Winther <mazewinther@gmail.com>2025-06-22 13:07:02 +0200
commitbe970248686c0af7d8506cba8c64bf507419da3d (patch)
tree3fd8a716b7adae452f1be6dcdd946533da47ad8a /apps/web/src/stores/timeline-store.ts
parentf2d27e578e6214598d36779f44fb1612764c7b3b (diff)
downloadopencut-be970248686c0af7d8506cba8c64bf507419da3d.tar.gz
so much stuff???
Diffstat (limited to 'apps/web/src/stores/timeline-store.ts')
-rw-r--r--apps/web/src/stores/timeline-store.ts61
1 files changed, 61 insertions, 0 deletions
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<TimelineClip, "id">) => void;
+}
+
+export const useTimelineStore = create<TimelineStore>((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
+ ),
+ }));
+ },
+}));