Open source CapCut alternative.
TypeScript
feat(site): give the side panel its own close button
David Lea5450c47c9d0
diff --git a/site/src/cut/components/AudioPanel.tsx b/site/src/cut/components/AudioPanel.tsxindex 9da3a2cd..f683c871 100644--- a/site/src/cut/components/AudioPanel.tsx+++ b/site/src/cut/components/AudioPanel.tsx@@ -79,6 +79,7 @@ export function AudioPanel({importing,sub,onSub,+ closeInset,}: {projectId: string;importing: boolean;@@ -86,6 +87,9 @@ export function AudioPanel({* two columns (this panel + the sample library) like the Image/Video tabs. */sub: "voice" | "music";onSub: (v: "voice" | "music") => void;+ /** When this is the panel's outermost column, the side panel's floating close+ * button sits on this corner; keep the toggle clear of it. */+ closeInset?: boolean;}) {const readOnly = useEditor((s) => s.readOnly);// The app-wide preview player: starting a clip stops the last one, here or@@ -107,7 +111,7 @@ export function AudioPanel({return (<>- <div className="shrink-0 px-3.5 pt-4 pb-3">+ <div className={cn("shrink-0 px-3.5 pt-4 pb-3", closeInset && "pr-12")}><AudioSubTabs value={sub} onChange={onSub} /></div>diff --git a/site/src/cut/components/SidePanel.tsx b/site/src/cut/components/SidePanel.tsxindex 29533448..4428544b 100644--- a/site/src/cut/components/SidePanel.tsx+++ b/site/src/cut/components/SidePanel.tsx@@ -1,7 +1,7 @@"use client";import { Fragment, useEffect, useRef, useState } from "react";-import { Captions, Check, Clapperboard, ClipboardList, Copy, Download, Ellipsis, Film, FolderOpen, FolderPlus, Image as ImageIcon, Loader2, Music, Plus, Trash2, Upload } from "lucide-react";+import { Captions, Check, Clapperboard, ClipboardList, Copy, Download, Ellipsis, Film, FolderOpen, FolderPlus, Image as ImageIcon, Loader2, Music, Plus, Trash2, Upload, X } from "lucide-react";import { Button } from "@/components/ui/button";import { LiveElapsed } from "@/cut/components/Elapsed";import {@@ -201,6 +201,10 @@ export function SidePanel({// collapse the panel so the canvas gets the room.usePanelRequestEffect(setTab);+ // The Audio tab's second column; when it's absent the audio generator is the+ // outermost column and takes the floating close button on its own corner.+ const musicLibrary = !sharedFeatures && audioSub === "music" && STOCK_MUSIC.length > 0;+return (<div className="flex min-h-0 border-r border-border bg-card">{/* Icon rail — its divider drops when collapsed so the panel's outer@@ -310,7 +314,9 @@ export function SidePanel({})}</div>- {tab === null ? null : tab === "image" || tab === "video" ? (+ {tab === null ? null : (+ <div className="relative flex min-h-0">+ {tab === "image" || tab === "video" ? (// The generate tabs are two columns: the generate input on the left,// the stock reference browser on the right. Clicking a stock tile loads// its prompt into the generate panel beside it.@@ -347,7 +353,7 @@ export function SidePanel({<divclassName={cn("flex w-[264px] min-h-0 shrink-0 flex-col",- !sharedFeatures && audioSub === "music" && STOCK_MUSIC.length > 0 && "border-r border-border"+ musicLibrary && "border-r border-border")}><AudioPanel@@ -355,9 +361,10 @@ export function SidePanel({importing={importing}sub={audioSub}onSub={setAudioSub}+ closeInset={!musicLibrary}/></div>- {!sharedFeatures && audioSub === "music" && STOCK_MUSIC.length > 0 && (+ {musicLibrary && (<div className="flex w-[340px] min-h-0 shrink-0 flex-col"><SampleLibrary projectId={projectId} /></div>@@ -372,6 +379,20 @@ export function SidePanel({{tab === "subtitles" && <SubtitlesPanel />}{tab === "publish" && <PublishPanel />}</div>+ )}+ {/* Floats over the panel's own header row; a solid face keeps it+ legible where a column scrolls beneath it. Same action as+ clicking the active rail tile. */}+ <button+ type="button"+ aria-label="Close panel"+ title="Close panel"+ className="absolute top-2.5 right-2.5 z-10 grid size-7 place-items-center rounded-md bg-card text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"+ onClick={() => setTab(null)}+ >+ <X className="size-4" />+ </button>+ </div>)}</div>);diff --git a/site/src/cut/components/StockMusicPanel.tsx b/site/src/cut/components/StockMusicPanel.tsxindex 052d16c6..075acfed 100644--- a/site/src/cut/components/StockMusicPanel.tsx+++ b/site/src/cut/components/StockMusicPanel.tsx@@ -51,8 +51,10 @@ export function SampleLibrary({ projectId }: { projectId: string }) {return (<>- {/* Chips sit at the same top inset as the left column's Voice/Music tabs. */}- <div className="shrink-0 px-3.5 pt-4 pb-3">+ {/* Chips sit at the same top inset as the left column's Voice/Music tabs.+ The right inset keeps the first row clear of the side panel's floating+ close button. */}+ <div className="shrink-0 pt-4 pr-12 pb-3 pl-3.5"><div className="flex flex-wrap gap-1.5"><Chip active={cat === "all"} onClick={() => setCat("all")}>Alldiff --git a/site/src/cut/components/StockVideosPanel.tsx b/site/src/cut/components/StockVideosPanel.tsxindex b028496f..e30be5f1 100644--- a/site/src/cut/components/StockVideosPanel.tsx+++ b/site/src/cut/components/StockVideosPanel.tsx@@ -101,10 +101,13 @@ export function StockVideosPanel() {</p>) : view === "root" ? (<>+ {/* The topmost section head shares its row with the side panel's+ floating close button; inset its View all clear of it. */}{characters.length > 0 && (<section className="shrink-0"><SectionHeadtitle="Talking Characters"+ className="pr-7"onViewAll={characters.length > SECTION_PREVIEW ? () => go("characters") : undefined}@@ -115,6 +118,7 @@ export function StockVideosPanel() {<section className="mt-3 shrink-0"><SectionHeadtitle="Stock Videos"+ className={characters.length === 0 ? "pr-7" : undefined}onViewAll={footage.length > SECTION_PREVIEW ? () => go("videos") : undefined}/>{footage.length > 0 ? (@@ -164,9 +168,17 @@ function Crumb({ title, onBack }: { title: string; onBack: () => void }) {);}-function SectionHead({ title, onViewAll }: { title: string; onViewAll?: () => void }) {+function SectionHead({+ title,+ onViewAll,+ className,+}: {+ title: string;+ onViewAll?: () => void;+ className?: string;+}) {return (- <div className="mb-1.5 flex items-center justify-between">+ <div className={cn("mb-1.5 flex items-center justify-between", className)}><span className="text-[12px] font-semibold">{title}</span>{onViewAll && <ViewAllButton onClick={onViewAll} />}</div>