From 0acead5bb19e57088b1dc664b3cbbafca10d3988 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Thu, 10 Jul 2025 21:24:47 +0200 Subject: refactor: move properties to dedicated folder --- .../editor/properties-panel/audio-properties.tsx | 5 ++ .../components/editor/properties-panel/index.tsx | 77 ++++++++++++++++++++++ .../editor/properties-panel/media-properties.tsx | 5 ++ .../editor/properties-panel/text-properties.tsx | 55 ++++++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 apps/web/src/components/editor/properties-panel/audio-properties.tsx create mode 100644 apps/web/src/components/editor/properties-panel/index.tsx create mode 100644 apps/web/src/components/editor/properties-panel/media-properties.tsx create mode 100644 apps/web/src/components/editor/properties-panel/text-properties.tsx (limited to 'apps/web/src/components/editor/properties-panel') diff --git a/apps/web/src/components/editor/properties-panel/audio-properties.tsx b/apps/web/src/components/editor/properties-panel/audio-properties.tsx new file mode 100644 index 00000000..384f0c5e --- /dev/null +++ b/apps/web/src/components/editor/properties-panel/audio-properties.tsx @@ -0,0 +1,5 @@ +import { MediaElement } from "@/types/timeline"; + +export function AudioProperties({ element }: { element: MediaElement }) { + return
Audio properties
; +} \ No newline at end of file diff --git a/apps/web/src/components/editor/properties-panel/index.tsx b/apps/web/src/components/editor/properties-panel/index.tsx new file mode 100644 index 00000000..0e6cb8a8 --- /dev/null +++ b/apps/web/src/components/editor/properties-panel/index.tsx @@ -0,0 +1,77 @@ +"use client"; + +import { useProjectStore } from "@/stores/project-store"; +import { useAspectRatio } from "@/hooks/use-aspect-ratio"; +import { Label } from "../../ui/label"; +import { ScrollArea } from "../../ui/scroll-area"; +import { useTimelineStore } from "@/stores/timeline-store"; +import { useMediaStore } from "@/stores/media-store"; +import { AudioProperties } from "./audio-properties"; +import { MediaProperties } from "./media-properties"; +import { TextProperties } from "./text-properties"; + +export function PropertiesPanel() { + const { activeProject } = useProjectStore(); + const { getDisplayName, canvasSize } = useAspectRatio(); + const { selectedElements, tracks } = useTimelineStore(); + const { mediaItems } = useMediaStore(); + + const emptyView = ( +
+ {/* Media Properties */} +
+ + + + +
+
+ ); + + return ( + + {selectedElements.length > 0 + ? selectedElements.map(({ trackId, elementId }) => { + const track = tracks.find((t) => t.id === trackId); + const element = track?.elements.find((e) => e.id === elementId); + + if (element?.type === "text") { + return ( +
+ +
+ ); + } + if (element?.type === "media") { + const mediaItem = mediaItems.find( + (item) => item.id === element.mediaId + ); + + if (mediaItem?.type === "audio") { + return ; + } + + return ( +
+ +
+ ); + } + return null; + }) + : emptyView} +
+ ); +} + +function PropertyItem({ label, value }: { label: string; value: string }) { + return ( +
+ + {value} +
+ ); +} diff --git a/apps/web/src/components/editor/properties-panel/media-properties.tsx b/apps/web/src/components/editor/properties-panel/media-properties.tsx new file mode 100644 index 00000000..c2c514cf --- /dev/null +++ b/apps/web/src/components/editor/properties-panel/media-properties.tsx @@ -0,0 +1,5 @@ +import { MediaElement } from "@/types/timeline"; + +export function MediaProperties({ element }: { element: MediaElement }) { + return
Media properties
; +} diff --git a/apps/web/src/components/editor/properties-panel/text-properties.tsx b/apps/web/src/components/editor/properties-panel/text-properties.tsx new file mode 100644 index 00000000..c28a9ed0 --- /dev/null +++ b/apps/web/src/components/editor/properties-panel/text-properties.tsx @@ -0,0 +1,55 @@ +import { Textarea } from "@/components/ui/textarea"; +import { Label } from "@/components/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { FONT_OPTIONS, FontFamily } from "@/constants/font-constants"; +import { TextElement } from "@/types/timeline"; +import { useTimelineStore } from "@/stores/timeline-store"; + +export function TextProperties({ + element, + trackId, +}: { + element: TextElement; + trackId: string; +}) { + const { updateTextElement } = useTimelineStore(); + + return ( +
+