mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
"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 = (
|
|||
|
|
<div className="space-y-4 p-5">
|
|||
|
|
{/* Media Properties */}
|
|||
|
|
<div className="flex flex-col gap-3">
|
|||
|
|
<PropertyItem label="Name:" value={activeProject?.name || ""} />
|
|||
|
|
<PropertyItem label="Aspect ratio:" value={getDisplayName()} />
|
|||
|
|
<PropertyItem
|
|||
|
|
label="Resolution:"
|
|||
|
|
value={`${canvasSize.width} × ${canvasSize.height}`}
|
|||
|
|
/>
|
|||
|
|
<PropertyItem label="Frame rate:" value="30.00fps" />
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
return (
|
|||
|
|
<ScrollArea className="h-full bg-panel rounded-sm">
|
|||
|
|
{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 (
|
|||
|
|
<div key={elementId}>
|
|||
|
|
<TextProperties element={element} trackId={trackId} />
|
|||
|
|
</div>
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
if (element?.type === "media") {
|
|||
|
|
const mediaItem = mediaItems.find(
|
|||
|
|
(item) => item.id === element.mediaId
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
if (mediaItem?.type === "audio") {
|
|||
|
|
return <AudioProperties element={element} />;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return (
|
|||
|
|
<div key={elementId}>
|
|||
|
|
<MediaProperties element={element} />
|
|||
|
|
</div>
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
return null;
|
|||
|
|
})
|
|||
|
|
: emptyView}
|
|||
|
|
</ScrollArea>
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function PropertyItem({ label, value }: { label: string; value: string }) {
|
|||
|
|
return (
|
|||
|
|
<div className="flex justify-between">
|
|||
|
|
<Label className="text-xs text-muted-foreground">{label}</Label>
|
|||
|
|
<span className="text-xs text-right">{value}</span>
|
|||
|
|
</div>
|
|||
|
|
);
|
|||
|
|
}
|