mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
feat: make settings items expandable
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
|||||||
PropertyItem,
|
PropertyItem,
|
||||||
PropertyItemLabel,
|
PropertyItemLabel,
|
||||||
PropertyItemValue,
|
PropertyItemValue,
|
||||||
|
PropertyGroup,
|
||||||
} from "../../properties-panel/property-item";
|
} from "../../properties-panel/property-item";
|
||||||
import { FPS_PRESETS } from "@/constants/timeline-constants";
|
import { FPS_PRESETS } from "@/constants/timeline-constants";
|
||||||
import { useProjectStore } from "@/stores/project-store";
|
import { useProjectStore } from "@/stores/project-store";
|
||||||
@@ -55,7 +56,7 @@ function ProjectSettingsTabs() {
|
|||||||
|
|
||||||
function ProjectInfoView() {
|
function ProjectInfoView() {
|
||||||
const { activeProject, updateProjectFps } = useProjectStore();
|
const { activeProject, updateProjectFps } = useProjectStore();
|
||||||
const { canvasSize, canvasPresets, setCanvasSize } = useEditorStore();
|
const { canvasPresets, setCanvasSize } = useEditorStore();
|
||||||
const { getDisplayName } = useAspectRatio();
|
const { getDisplayName } = useAspectRatio();
|
||||||
|
|
||||||
const handleAspectRatioChange = (value: string) => {
|
const handleAspectRatioChange = (value: string) => {
|
||||||
@@ -147,7 +148,7 @@ const BlurPreview = memo(
|
|||||||
fill
|
fill
|
||||||
className="object-cover"
|
className="object-cover"
|
||||||
style={{ filter: `blur(${blur.value}px)` }}
|
style={{ filter: `blur(${blur.value}px)` }}
|
||||||
priority
|
loading="eager"
|
||||||
/>
|
/>
|
||||||
<div className="absolute bottom-1 left-1 right-1 text-center">
|
<div className="absolute bottom-1 left-1 right-1 text-center">
|
||||||
<span className="text-xs text-white bg-black/50 px-1 rounded">
|
<span className="text-xs text-white bg-black/50 px-1 rounded">
|
||||||
@@ -223,24 +224,19 @@ function BackgroundView() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-5">
|
||||||
<PropertyItem direction="column" className="gap-2">
|
<PropertyGroup title="Blur">
|
||||||
<PropertyItemLabel>Blur</PropertyItemLabel>
|
<div className="grid grid-cols-4 gap-2 w-full">{blurPreviews}</div>
|
||||||
<PropertyItemValue>
|
</PropertyGroup>
|
||||||
<div className="grid grid-cols-4 gap-2 w-full">{blurPreviews}</div>
|
|
||||||
</PropertyItemValue>
|
<PropertyGroup title="Color">
|
||||||
</PropertyItem>
|
<div className="grid grid-cols-4 gap-2 w-full">
|
||||||
<PropertyItem direction="column" className="gap-2">
|
<div className="w-full aspect-square rounded-sm cursor-pointer border border-foreground/15 hover:border-primary flex items-center justify-center">
|
||||||
<PropertyItemLabel>Color</PropertyItemLabel>
|
<PipetteIcon className="size-4" />
|
||||||
<PropertyItemValue>
|
|
||||||
<div className="grid grid-cols-4 gap-2 w-full">
|
|
||||||
<div className="w-full aspect-square rounded-sm cursor-pointer border border-foreground/15 hover:border-primary flex items-center justify-center">
|
|
||||||
<PipetteIcon className="size-4" />
|
|
||||||
</div>
|
|
||||||
{colorPreviews}
|
|
||||||
</div>
|
</div>
|
||||||
</PropertyItemValue>
|
{colorPreviews}
|
||||||
</PropertyItem>
|
</div>
|
||||||
|
</PropertyGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { ChevronDown } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
interface PropertyItemProps {
|
interface PropertyItemProps {
|
||||||
direction?: "row" | "column";
|
direction?: "row" | "column";
|
||||||
@@ -49,3 +51,34 @@ export function PropertyItemValue({
|
|||||||
}) {
|
}) {
|
||||||
return <div className={cn("flex-1 text-sm", className)}>{children}</div>;
|
return <div className={cn("flex-1 text-sm", className)}>{children}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface PropertyGroupProps {
|
||||||
|
title: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
defaultExpanded?: boolean;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PropertyGroup({
|
||||||
|
title,
|
||||||
|
children,
|
||||||
|
defaultExpanded = true,
|
||||||
|
className,
|
||||||
|
}: PropertyGroupProps) {
|
||||||
|
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PropertyItem direction="column" className={cn("gap-3", className)}>
|
||||||
|
<div
|
||||||
|
className="flex items-center gap-1.5 cursor-pointer"
|
||||||
|
onClick={() => setIsExpanded(!isExpanded)}
|
||||||
|
>
|
||||||
|
<PropertyItemLabel className="cursor-pointer">
|
||||||
|
{title}
|
||||||
|
</PropertyItemLabel>
|
||||||
|
<ChevronDown className={cn("size-3", !isExpanded && "-rotate-90")} />
|
||||||
|
</div>
|
||||||
|
{isExpanded && <PropertyItemValue>{children}</PropertyItemValue>}
|
||||||
|
</PropertyItem>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user