The open-source CapCut alternative
feat: make settings items expandable
Maze Winther7891ed2cc148
diff --git a/apps/web/src/components/editor/media-panel/views/settings.tsx b/apps/web/src/components/editor/media-panel/views/settings.tsxindex 54387dd7..cdfa36f2 100644--- a/apps/web/src/components/editor/media-panel/views/settings.tsx+++ b/apps/web/src/components/editor/media-panel/views/settings.tsx@@ -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(fillclassName="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>);}diff --git a/apps/web/src/components/editor/properties-panel/property-item.tsx b/apps/web/src/components/editor/properties-panel/property-item.tsxindex 86a8d378..dc6b6d74 100644--- a/apps/web/src/components/editor/properties-panel/property-item.tsx+++ b/apps/web/src/components/editor/properties-panel/property-item.tsx@@ -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>+ );+}