blob: 75dd81a9623c3058b9327ee7132b18963196e07b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
"use client";
import { ScrollArea } from "@/components/ui/scroll-area";
import { AudioProperties } from "./audio-properties";
import { VideoProperties } from "./video-properties";
import { TextProperties } from "./text-properties";
import { EffectProperties } from "./effect-properties";
import { EmptyView } from "./empty-view";
import { useEditor } from "@/hooks/use-editor";
import { useElementSelection } from "@/hooks/timeline/element/use-element-selection";
import type { TimelineElement, TimelineTrack } from "@/types/timeline";
function ElementProperties({
track,
element,
}: {
track: TimelineTrack;
element: TimelineElement;
}) {
if (element.type === "text") {
return <TextProperties element={element} trackId={track.id} />;
}
if (element.type === "audio") {
return <AudioProperties _element={element} />;
}
if (
element.type === "video" ||
element.type === "image" ||
element.type === "sticker"
) {
return <VideoProperties element={element} trackId={track.id} />;
}
if (element.type === "effect") {
return <EffectProperties element={element} trackId={track.id} />;
}
return null;
}
export function PropertiesPanel() {
const editor = useEditor();
const { selectedElements } = useElementSelection();
const elementsWithTracks = editor.timeline.getElementsWithTracks({
elements: selectedElements,
});
const hasSelection = selectedElements.length > 0;
return (
<div className="panel bg-background h-full rounded-sm border overflow-hidden">
{hasSelection ? (
<ScrollArea className="h-full scrollbar-hidden">
{elementsWithTracks.map(({ track, element }) => (
<ElementProperties
key={element.id}
track={track}
element={element}
/>
))}
</ScrollArea>
) : (
<EmptyView />
)}
</div>
);
}
|