feat: make settings items expandable

This commit is contained in:
Maze Winther
2025-08-02 12:21:24 +02:00
parent dd09bf2949
commit 7891ed2cc1
2 changed files with 48 additions and 19 deletions
@@ -14,6 +14,7 @@ import {
PropertyItem,
PropertyItemLabel,
PropertyItemValue,
PropertyGroup,
} from "../../properties-panel/property-item";
import { FPS_PRESETS } from "@/constants/timeline-constants";
import { useProjectStore } from "@/stores/project-store";
@@ -55,7 +56,7 @@ function ProjectSettingsTabs() {
function ProjectInfoView() {
const { activeProject, updateProjectFps } = useProjectStore();
const { canvasSize, canvasPresets, setCanvasSize } = useEditorStore();
const { canvasPresets, setCanvasSize } = useEditorStore();
const { getDisplayName } = useAspectRatio();
const handleAspectRatioChange = (value: string) => {
@@ -147,7 +148,7 @@ const BlurPreview = memo(
fill
className="object-cover"
style={{ filter: `blur(${blur.value}px)` }}
priority
loading="eager"
/>
<div className="absolute bottom-1 left-1 right-1 text-center">
<span className="text-xs text-white bg-black/50 px-1 rounded">
@@ -223,24 +224,19 @@ function BackgroundView() {
);
return (
<div className="flex flex-col gap-4">
<PropertyItem direction="column" className="gap-2">
<PropertyItemLabel>Blur</PropertyItemLabel>
<PropertyItemValue>
<div className="grid grid-cols-4 gap-2 w-full">{blurPreviews}</div>
</PropertyItemValue>
</PropertyItem>
<PropertyItem direction="column" className="gap-2">
<PropertyItemLabel>Color</PropertyItemLabel>
<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 className="flex flex-col gap-5">
<PropertyGroup title="Blur">
<div className="grid grid-cols-4 gap-2 w-full">{blurPreviews}</div>
</PropertyGroup>
<PropertyGroup title="Color">
<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>
</PropertyItemValue>
</PropertyItem>
{colorPreviews}
</div>
</PropertyGroup>
</div>
);
}
@@ -1,4 +1,6 @@
import { cn } from "@/lib/utils";
import { ChevronDown } from "lucide-react";
import { useState } from "react";
interface PropertyItemProps {
direction?: "row" | "column";
@@ -49,3 +51,34 @@ export function PropertyItemValue({
}) {
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>
);
}