Skip to content

Open source CapCut alternative.

TypeScript

feat(cut): effects panel with tile grids and live previews

David Le684d2ec02f22
diff --git a/site/src/cut/components/ClipEffectsPanel.tsx b/site/src/cut/components/ClipEffectsPanel.tsx
new file mode 100644
index 00000000..7af7a8a1
--- /dev/null
+++ b/site/src/cut/components/ClipEffectsPanel.tsx
@@ -0,0 +1,508 @@
+"use client";
+
+import { Fragment, useRef, useState } from "react";
+import {
+ ArrowDown,
+ ArrowDownToLine,
+ ArrowLeft,
+ ArrowLeftToLine,
+ ArrowRight,
+ ArrowRightToLine,
+ ArrowUp,
+ ArrowUpToLine,
+ Ban,
+ Blend,
+ ChevronLeft,
+ Circle,
+ Droplets,
+ Expand,
+ FoldHorizontal,
+ Haze,
+ Moon,
+ Sparkles,
+ Sun,
+ Target,
+ UnfoldHorizontal,
+ ZoomIn,
+ type LucideIcon,
+} from "lucide-react";
+import { Slider } from "@/components/ui/slider";
+import { parsePercentInput, parseSecondsInput, ScrubValue } from "@/cut/components/ScrubValue";
+import { getClipSpans, useEditor } from "@/cut/lib/store";
+import { lookCssFilter } from "@/cut/lib/looks";
+import {
+ ANIM_DEFAULT_SECONDS,
+ ANIM_STYLE_IDS,
+ ANIM_STYLE_LABELS,
+ LOOK_IDS,
+ LOOK_LABELS,
+ TRANSITION_MAX,
+ TRANSITION_STYLE_GROUPS,
+ TRANSITION_STYLE_LABELS,
+ type AnimStyle,
+ type LookStyle,
+ type TransitionStyle,
+ type VideoClip,
+} from "@/cut/lib/types";
+import { cn } from "@/lib/utils";
+
+const TRANSITION_TILE_ICONS: Record<TransitionStyle, LucideIcon> = {
+ crossfade: Blend,
+ crosszoom: Expand,
+ dipblack: Moon,
+ dipwhite: Sun,
+ blur: Droplets,
+ pushleft: ArrowLeft,
+ pushright: ArrowRight,
+ pushup: ArrowUp,
+ pushdown: ArrowDown,
+ wipeleft: ArrowLeftToLine,
+ wiperight: ArrowRightToLine,
+ wipeup: ArrowUpToLine,
+ wipedown: ArrowDownToLine,
+ circleopen: Circle,
+ circleclose: Target,
+ splitopen: UnfoldHorizontal,
+ splitclose: FoldHorizontal,
+};
+
+const ANIM_TILE_ICONS: Record<AnimStyle, LucideIcon> = {
+ fade: Haze,
+ zoom: ZoomIn,
+ pop: Sparkles,
+ slideleft: ArrowLeft,
+ slideright: ArrowRight,
+ slideup: ArrowUp,
+ slidedown: ArrowDown,
+};
+
+/** The entry row's compact readout: which effect categories are set (the row
+ * is 8.5rem wide — exact style names don't fit, the tabs inside do). */
+export function effectsSummary(clip: VideoClip, hasNext: boolean): string {
+ const parts: string[] = [];
+ if (hasNext && (clip.transition ?? 0) > 0) parts.push("Transition");
+ if (clip.animIn) parts.push("In");
+ if (clip.animOut) parts.push("Out");
+ if (clip.look) parts.push("Look");
+ return parts.join(" · ") || "None";
+}
+
+/** One undo checkpoint per slider drag (mirrors the Inspector's helper —
+ * importing it would cycle back through Inspector). */
+function useSliderCheckpoint() {
+ const active = useRef(false);
+ return {
+ begin() {
+ if (active.current) return;
+ active.current = true;
+ useEditor.getState().pushHistory();
+ },
+ end() {
+ active.current = false;
+ },
+ };
+}
+
+function Tile({
+ selected,
+ onClick,
+ label,
+ className,
+ children,
+}: {
+ selected: boolean;
+ onClick: () => void;
+ label: string;
+ className?: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <button
+ type="button"
+ aria-pressed={selected}
+ className={cn(
+ "flex flex-col items-center gap-1.5 rounded-lg border border-border p-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",
+ selected && "bg-primary/10 text-foreground ring-2 ring-[#0a84ff] ring-offset-1 ring-offset-card",
+ className
+ )}
+ onClick={onClick}
+ >
+ {children}
+ <span className="leading-none">{label}</span>
+ </button>
+ );
+}
+
+function GridLabel({ children }: { children: React.ReactNode }) {
+ return (
+ <div className="col-span-2 mt-1.5 text-[10.5px] font-semibold uppercase tracking-wide text-muted-foreground/70 first:mt-0">
+ {children}
+ </div>
+ );
+}
+
+type Tab = "transition" | "in" | "out" | "looks";
+
+/**
+ * The effects sub-page a clip panel pushes into: segmented tabs over card
+ * grids — the transition into the next clip, the clip's own entrance/exit
+ * animations, and its filter look — with the active effect's duration or
+ * intensity slider beneath the grid.
+ */
+export function ClipEffectsPanel({
+ clip,
+ hasNext,
+ onBack,
+}: {
+ clip: VideoClip;
+ hasNext: boolean;
+ onBack: () => void;
+}) {
+ const [tab, setTab] = useState<Tab>(hasNext ? "transition" : "in");
+ const [xfadeDraft, setXfadeDraft] = useState<number | null>(null);
+ const ck = useSliderCheckpoint();
+ // Upper tracks composite via alpha, so only the animations expressible as
+ // alpha/zoom ramps are offered there (the rest would silently degrade).
+ const animStyles = clip.track > 0 ? (["fade", "zoom"] as AnimStyle[]) : ANIM_STYLE_IDS;
+ const xfade = xfadeDraft ?? clip.transition ?? 0;
+
+ // Picking or retuning an effect immediately plays the affected stretch of
+ // the real timeline in the preview — seek just ahead of it, play, and
+ // auto-pause just after — so every option shows itself on the actual
+ // footage. Windows are computed from fresh state (setting a transition can
+ // slide the following clips).
+ const PREVIEW_LEAD = 0.4;
+ const PREVIEW_TAIL = 0.35;
+ const previewTransition = () => {
+ const s = useEditor.getState();
+ const spans = getClipSpans(s.clips, s.assets, clip.track);
+ const i = spans.findIndex((sp) => sp.clip.id === clip.id);
+ const sp = spans[i];
+ const next = spans[i + 1];
+ if (!sp || !next || sp.transitionOut <= 0) return;
+ s.previewRange(next.start - PREVIEW_LEAD, next.start + sp.transitionOut + PREVIEW_TAIL);
+ };
+ const previewAnim = (which: "in" | "out") => {
+ const s = useEditor.getState();
+ const sp = getClipSpans(s.clips, s.assets, clip.track).find((x) => x.clip.id === clip.id);
+ const fresh = s.clips.find((c) => c.id === clip.id);
+ const a = which === "in" ? fresh?.animIn : fresh?.animOut;
+ if (!sp || !a) return;
+ if (which === "in") s.previewRange(sp.start - 0.25, sp.start + a.seconds + PREVIEW_TAIL);
+ else s.previewRange(sp.start + sp.len - a.seconds - PREVIEW_LEAD, sp.start + sp.len + 0.25);
+ };
+ const previewLook = () => {
+ // A look is static — landing the playhead on the clip's own footage
+ // shows it instantly; no play-through needed.
+ const s = useEditor.getState();
+ const sp = getClipSpans(s.clips, s.assets, clip.track).find((x) => x.clip.id === clip.id);
+ if (!sp) return;
+ if (s.currentTime < sp.start || s.currentTime >= sp.start + sp.len) {
+ s.seek(sp.start + sp.len / 2);
+ }
+ };
+
+ const pickTransition = (style: TransitionStyle | null) => {
+ // Picking a style with the length still at zero turns the transition on
+ // at a sensible default.
+ if (style === null) {
+ useEditor.getState().setClipTransition(clip.id, 0);
+ return;
+ }
+ useEditor.getState().setClipTransition(clip.id, xfade >= 0.05 ? xfade : 0.5, style);
+ previewTransition();
+ };
+ const pickAnim = (which: "in" | "out", style: AnimStyle | null) => {
+ const current = which === "in" ? clip.animIn : clip.animOut;
+ useEditor
+ .getState()
+ .setClipAnim(
+ clip.id,
+ which,
+ style ? { style, seconds: current?.seconds ?? ANIM_DEFAULT_SECONDS } : null
+ );
+ if (style) previewAnim(which);
+ };
+ const setAnimSeconds = (which: "in" | "out", seconds: number) => {
+ const current = which === "in" ? clip.animIn : clip.animOut;
+ if (!current) return;
+ ck.begin();
+ useEditor.getState().updateClipTransient(clip.id, {
+ [which === "in" ? "animIn" : "animOut"]: {
+ style: current.style,
+ seconds: Math.max(0.1, Math.min(TRANSITION_MAX, seconds)),
+ },
+ });
+ };
+ const setLookAmount = (v: number) => {
+ if (!clip.look) return;
+ ck.begin();
+ useEditor.getState().updateClipTransient(clip.id, {
+ lookAmount: v >= 1 ? undefined : Math.max(0.05, v),
+ });
+ };
+
+ const tabs: { id: Tab; label: string; disabled?: boolean; title?: string }[] = [
+ {
+ id: "transition",
+ label: "Transition",
+ disabled: !hasNext,
+ title: hasNext ? undefined : "Needs a following clip on this track",
+ },
+ { id: "in", label: "In" },
+ { id: "out", label: "Out" },
+ { id: "looks", label: "Looks" },
+ ];
+ // Never sit on a disabled tab (e.g. picking a transition disables Out while
+ // Out is open): fall to the first enabled one.
+ const activeTab = tabs.find((t) => t.id === tab && !t.disabled)
+ ? tab
+ : (tabs.find((t) => !t.disabled)?.id ?? "looks");
+ const anim = activeTab === "in" ? clip.animIn : activeTab === "out" ? clip.animOut : undefined;
+
+ return (
+ <>
+ <div className="flex h-10 shrink-0 items-center gap-1 px-2.5 text-sm font-semibold tracking-tight">
+ <button
+ type="button"
+ aria-label="Back"
+ className="clip-fx-back grid size-6 place-items-center rounded text-muted-foreground transition-colors hover:text-foreground"
+ onClick={onBack}
+ >
+ <ChevronLeft className="size-4" />
+ </button>
+ Effects
+ </div>
+ <div className="flex flex-col gap-2 px-3.5 pb-4">
+ <div className="flex shrink-0 rounded-lg bg-muted p-0.5 text-[11.5px] font-medium">
+ {tabs.map((t) => (
+ <button
+ key={t.id}
+ type="button"
+ disabled={t.disabled}
+ title={t.title}
+ className={cn(
+ "clip-fx-tab flex-1 rounded-md px-1.5 py-1 transition-colors",
+ activeTab === t.id
+ ? "bg-neutral-900 text-white"
+ : "text-muted-foreground hover:text-foreground",
+ t.disabled && "cursor-not-allowed opacity-40 hover:text-muted-foreground"
+ )}
+ onClick={() => !t.disabled && setTab(t.id)}
+ >
+ {t.label}
+ </button>
+ ))}
+ </div>
+
+ {activeTab === "transition" && (
+ <>
+ <div className="grid grid-cols-2 gap-1.5">
+ <Tile
+ selected={(clip.transition ?? 0) <= 0}
+ onClick={() => pickTransition(null)}
+ label="None"
+ className="clip-fx-none"
+ >
+ <Ban className="size-4" />
+ </Tile>
+ {TRANSITION_STYLE_GROUPS.map((g) => (
+ <Fragment key={g.label}>
+ <GridLabel>{g.label}</GridLabel>
+ {g.ids.map((id) => {
+ const Icon = TRANSITION_TILE_ICONS[id];
+ return (
+ <Tile
+ key={id}
+ selected={
+ (clip.transition ?? 0) > 0 && (clip.transitionStyle ?? "crossfade") === id
+ }
+ onClick={() => pickTransition(id)}
+ label={TRANSITION_STYLE_LABELS[id]}
+ className={`clip-fx-t-${id}`}
+ >
+ <Icon className="size-4" />
+ </Tile>
+ );
+ })}
+ </Fragment>
+ ))}
+ </div>
+ {(clip.transition ?? 0) > 0 && (
+ <div className="flex items-center gap-2 pt-1">
+ <span className="w-14 shrink-0 text-[11.5px] text-muted-foreground">Length</span>
+ <Slider
+ className="clip-xfade data-horizontal:w-24"
+ min={0.1}
+ max={TRANSITION_MAX}
+ step={0.1}
+ value={xfade}
+ onValueChange={(v) => setXfadeDraft(Number(v))}
+ onValueCommitted={() => {
+ if (xfadeDraft != null) {
+ useEditor.getState().setClipTransition(clip.id, xfadeDraft);
+ previewTransition();
+ }
+ setXfadeDraft(null);
+ }}
+ />
+ <ScrubValue
+ label="Transition length"
+ className="w-9 text-muted-foreground"
+ value={xfade}
+ min={0}
+ max={TRANSITION_MAX}
+ step={0.1}
+ format={(v) => `${v.toFixed(1)}s`}
+ parse={parseSecondsInput}
+ onScrub={setXfadeDraft}
+ onCommit={(v) => {
+ useEditor.getState().setClipTransition(clip.id, v);
+ previewTransition();
+ setXfadeDraft(null);
+ }}
+ />
+ </div>
+ )}
+ </>
+ )}
+
+ {(activeTab === "in" || activeTab === "out") && (
+ <>
+ <div className="grid grid-cols-2 gap-1.5">
+ <Tile
+ selected={!anim}
+ onClick={() => pickAnim(activeTab, null)}
+ label="None"
+ className="clip-fx-none"
+ >
+ <Ban className="size-4" />
+ </Tile>
+ {animStyles.map((id) => {
+ const Icon = ANIM_TILE_ICONS[id];
+ return (
+ <Tile
+ key={id}
+ selected={anim?.style === id}
+ onClick={() => pickAnim(activeTab, id)}
+ label={ANIM_STYLE_LABELS[id]}
+ className={`clip-fx-a-${id}`}
+ >
+ <Icon className="size-4" />
+ </Tile>
+ );
+ })}
+ </div>
+ {anim && (
+ <div className="flex items-center gap-2 pt-1">
+ <span className="w-14 shrink-0 text-[11.5px] text-muted-foreground">Length</span>
+ <Slider
+ className="clip-fx-anim-secs data-horizontal:w-24"
+ min={0.1}
+ max={TRANSITION_MAX}
+ step={0.1}
+ value={anim.seconds}
+ onValueChange={(v) => setAnimSeconds(activeTab, Number(v))}
+ onValueCommitted={() => {
+ ck.end();
+ previewAnim(activeTab);
+ }}
+ />
+ <ScrubValue
+ label="Animation length"
+ className="w-9 text-muted-foreground"
+ value={anim.seconds}
+ min={0.1}
+ max={TRANSITION_MAX}
+ step={0.1}
+ format={(v) => `${v.toFixed(1)}s`}
+ parse={parseSecondsInput}
+ onScrub={(v) => setAnimSeconds(activeTab, v)}
+ onCommit={(v) => {
+ setAnimSeconds(activeTab, v);
+ ck.end();
+ previewAnim(activeTab);
+ }}
+ />
+ </div>
+ )}
+ </>
+ )}
+
+ {activeTab === "looks" && (
+ <>
+ <div className="grid grid-cols-2 gap-1.5">
+ <Tile
+ selected={!clip.look}
+ onClick={() => useEditor.getState().setClipLook(clip.id, null)}
+ label="None"
+ className="clip-fx-none"
+ >
+ <LookSwatch />
+ </Tile>
+ {LOOK_IDS.map((id) => (
+ <Tile
+ key={id}
+ selected={clip.look === id}
+ onClick={() => {
+ useEditor.getState().setClipLook(clip.id, id, clip.lookAmount);
+ previewLook();
+ }}
+ label={LOOK_LABELS[id]}
+ className={`clip-fx-l-${id}`}
+ >
+ <LookSwatch look={id} />
+ </Tile>
+ ))}
+ </div>
+ {clip.look && (
+ <div className="flex items-center gap-2 pt-1">
+ <span className="w-14 shrink-0 text-[11.5px] text-muted-foreground">Intensity</span>
+ <Slider
+ className="clip-fx-look-amount data-horizontal:w-24"
+ min={0.05}
+ max={1}
+ step={0.05}
+ value={clip.lookAmount ?? 1}
+ onValueChange={(v) => setLookAmount(Number(v))}
+ onValueCommitted={() => ck.end()}
+ />
+ <ScrubValue
+ label="Look intensity"
+ className="w-9 text-muted-foreground"
+ value={clip.lookAmount ?? 1}
+ min={0.05}
+ max={1}
+ step={0.05}
+ format={(v) => `${Math.round(v * 100)}%`}
+ parse={parsePercentInput}
+ onScrub={setLookAmount}
+ onCommit={(v) => {
+ setLookAmount(v);
+ ck.end();
+ }}
+ />
+ </div>
+ )}
+ </>
+ )}
+ </div>
+ </>
+ );
+}
+
+/** A look tile's thumbnail: one shared colorful gradient run through the
+ * look's own CSS filter, so the tiles are the single source of truth with the
+ * preview grading. No look = the unfiltered gradient. */
+function LookSwatch({ look }: { look?: LookStyle }) {
+ return (
+ <span
+ aria-hidden
+ className="h-8 w-full rounded-md"
+ style={{
+ background: "linear-gradient(135deg,#f59e0b 0%,#ec4899 50%,#3b82f6 100%)",
+ filter: look ? lookCssFilter(look, 1) || undefined : undefined,
+ }}
+ />
+ );
+}
diff --git a/site/src/cut/components/Inspector.tsx b/site/src/cut/components/Inspector.tsx
index 6457a2f1..30c5e8f8 100644
--- a/site/src/cut/components/Inspector.tsx
+++ b/site/src/cut/components/Inspector.tsx
@@ -20,7 +20,7 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { Textarea } from "@/components/ui/textarea";
-import { track0Clips, clipWindow, useEditor, type EditorState } from "@/cut/lib/store";
+import { clipWindow, useEditor, type EditorState } from "@/cut/lib/store";
import { GenerateSubtitlesAudio } from "@/cut/components/VoicePicker";
import {
parseNumberInput,
@@ -43,17 +43,14 @@ import {
SPEED_FLOOR,
SPEED_MAX,
SPEED_MIN,
- TRANSITION_MAX,
- TRANSITION_STYLE_IDS,
- TRANSITION_STYLE_LABELS,
type AudioClip,
type ColorGrade,
type FrameRect,
type LayoutId,
type TextOverlay,
- type TransitionStyle,
type VideoClip,
} from "@/cut/lib/types";
+import { ClipEffectsPanel, effectsSummary } from "@/cut/components/ClipEffectsPanel";
import { autoGradeFromImageData, isNeutralGrade, normalizeGrade } from "@/cut/lib/colorGrade";
import { getPreviewCanvas, sampleClipFrameData } from "@/cut/lib/previewCanvas";
import { cn } from "@/lib/utils";
@@ -230,14 +227,20 @@ const Value = ({ children, className }: { children: React.ReactNode; className?:
/** Matches the store's MIN_LEN: the shortest a trim can leave a clip. */
const MIN_TRIM = 0.1;
-/** Sits at the right end of a row once its value has moved off the default. */
-function ResetButton({ title, onClick }: { title: string; onClick: () => void }) {
+/** Sits at the right end of a row, visible once its value has moved off the
+ * default. Always occupies its slot so the row doesn't shift when it appears. */
+function ResetButton({ title, show, onClick }: { title: string; show: boolean; onClick: () => void }) {
return (
<button
type="button"
title={title}
aria-label={title}
- className="grid size-5 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:text-foreground"
+ aria-hidden={!show}
+ tabIndex={show ? undefined : -1}
+ className={cn(
+ "grid size-5 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:text-foreground",
+ !show && "invisible",
+ )}
onClick={onClick}
>
<RotateCcw className="size-3" />
@@ -246,7 +249,6 @@ function ResetButton({ title, onClick }: { title: string; onClick: () => void })
}
const formatSpeed = (v: number) => `${v.toFixed(2)}×`;
-const formatFade = (v: number) => (v < 0.05 ? "Off" : `${v.toFixed(1)}s`);
const formatPercent = (v: number) => `${Math.round(v * 100)}%`;
/** One-click frame layouts (Full / Top / Bottom / Left / Right / PiP) shared by
@@ -297,26 +299,17 @@ function ClipPanel({ clip }: { clip: VideoClip }) {
const hasNext = useEditor((s) =>
s.clips.some((c) => c.track === clip.track && c.start > clip.start + 1e-6)
);
- // The whole-video fades are project-level but live on the clips that show
- // them: fade in on the first clip's panel, fade out on the last clip's.
- const isFirst = useEditor((s) => track0Clips(s.clips)[0]?.id === clip.id);
- const isLast = useEditor((s) => {
- const row = track0Clips(s.clips);
- return row[row.length - 1]?.id === clip.id;
- });
- const fadeIn = useEditor((s) => s.fadeIn);
- const fadeOut = useEditor((s) => s.fadeOut);
const [speedDraft, setSpeedDraft] = useState<number | null>(null);
- const [xfadeDraft, setXfadeDraft] = useState<number | null>(null);
const [volumeDraft, setVolumeDraft] = useState<number | null>(null);
- // The panel can push into the color-grade subview. The subview remembers
- // which clip opened it, so selecting another clip lands back on the main
- // view without an effect.
+ // The panel can push into the color-grade or effects subview. Each subview
+ // remembers which clip opened it, so selecting another clip lands back on
+ // the main view without an effect.
const [colorFor, setColorFor] = useState<string | null>(null);
- const view = colorFor === clip.id ? "color" : "main";
+ const [effectsFor, setEffectsFor] = useState<string | null>(null);
+ const view =
+ colorFor === clip.id ? "color" : effectsFor === clip.id ? "effects" : "main";
const volume = volumeDraft ?? clip.volume ?? 1;
const speed = speedDraft ?? clip.speed ?? 1;
- const xfade = xfadeDraft ?? clip.transition ?? 0;
const speedLen = (clip.out - clip.in) / (speed > 0 ? speed : 1);
// Typing can trim out to the source's end but no further; an image has no
// intrinsic duration, so its clip can be any length.
@@ -324,6 +317,9 @@ function ClipPanel({ clip }: { clip: VideoClip }) {
if (view === "color") {
return <ColorPanel clip={clip} onBack={() => setColorFor(null)} />;
}
+ if (view === "effects") {
+ return <ClipEffectsPanel clip={clip} hasNext={hasNext} onBack={() => setEffectsFor(null)} />;
+ }
return (
<>
<PanelTitle>Video clip</PanelTitle>
@@ -358,12 +354,11 @@ function ClipPanel({ clip }: { clip: VideoClip }) {
parse={parseTimeInput}
onCommit={(v) => useEditor.getState().setClipTrim(clip.id, clip.in, v)}
/>
- {Number.isFinite(maxOut) && (clip.in > 1e-3 || clip.out < maxOut - 1e-3) && (
- <ResetButton
- title="Reset trim"
- onClick={() => useEditor.getState().setClipTrim(clip.id, 0, maxOut)}
- />
- )}
+ <ResetButton
+ title="Reset trim"
+ show={Number.isFinite(maxOut) && (clip.in > 1e-3 || clip.out < maxOut - 1e-3)}
+ onClick={() => useEditor.getState().setClipTrim(clip.id, 0, maxOut)}
+ />
</Row>
<Row label="Starts at">
<ScrubValue
@@ -409,15 +404,14 @@ function ClipPanel({ clip }: { clip: VideoClip }) {
setSpeedDraft(null);
}}
/>
- {Math.abs(speed - 1) > 1e-4 && (
- <ResetButton
- title="Reset speed"
- onClick={() => {
- useEditor.getState().setClipSpeed(clip.id, 1);
- setSpeedDraft(null);
- }}
- />
- )}
+ <ResetButton
+ title="Reset speed"
+ show={Math.abs(speed - 1) > 1e-4}
+ onClick={() => {
+ useEditor.getState().setClipSpeed(clip.id, 1);
+ setSpeedDraft(null);
+ }}
+ />
</Row>
<Row label="Color">
<button
@@ -435,111 +429,16 @@ function ClipPanel({ clip }: { clip: VideoClip }) {
<ChevronRight className="size-3.5" />
</button>
</Row>
- {isFirst && (
- <Row label="Fade in">
- <Slider
- className="project-fade-in data-horizontal:w-24"
- min={0}
- max={TRANSITION_MAX}
- step={0.1}
- value={fadeIn}
- onValueChange={(v) => useEditor.getState().setProjectFade({ fadeIn: Number(v) })}
- />
- <ScrubValue
- label="Fade in"
- className="w-9 text-muted-foreground"
- value={fadeIn}
- min={0}
- max={TRANSITION_MAX}
- step={0.1}
- format={formatFade}
- parse={parseSecondsInput}
- onScrub={(v) => useEditor.getState().setProjectFade({ fadeIn: v })}
- onCommit={(v) => useEditor.getState().setProjectFade({ fadeIn: v })}
- />
- </Row>
- )}
- {isLast && (
- <Row label="Fade out">
- <Slider
- className="project-fade-out data-horizontal:w-24"
- min={0}
- max={TRANSITION_MAX}
- step={0.1}
- value={fadeOut}
- onValueChange={(v) => useEditor.getState().setProjectFade({ fadeOut: Number(v) })}
- />
- <ScrubValue
- label="Fade out"
- className="w-9 text-muted-foreground"
- value={fadeOut}
- min={0}
- max={TRANSITION_MAX}
- step={0.1}
- format={formatFade}
- parse={parseSecondsInput}
- onScrub={(v) => useEditor.getState().setProjectFade({ fadeOut: v })}
- onCommit={(v) => useEditor.getState().setProjectFade({ fadeOut: v })}
- />
- </Row>
- )}
- {hasNext && (
- <>
- <Row label="Transition">
- <Select
- value={clip.transitionStyle ?? "crossfade"}
- items={TRANSITION_STYLE_LABELS}
- onValueChange={(v) =>
- // Picking a style with the length still at zero turns the
- // transition on at a sensible default.
- useEditor
- .getState()
- .setClipTransition(clip.id, xfade >= 0.05 ? xfade : 0.5, v as TransitionStyle)
- }
- >
- <SelectTrigger className="clip-transition-style h-7 w-[8.5rem] text-[12px]">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {TRANSITION_STYLE_IDS.map((id) => (
- <SelectItem key={id} value={id} className="text-[12px]">
- {TRANSITION_STYLE_LABELS[id]}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </Row>
- <Row label="Length">
- <Slider
- className="clip-xfade data-horizontal:w-24"
- min={0}
- max={TRANSITION_MAX}
- step={0.1}
- value={xfade}
- onValueChange={(v) => setXfadeDraft(Number(v))}
- onValueCommitted={() => {
- if (xfadeDraft != null) useEditor.getState().setClipTransition(clip.id, xfadeDraft);
- setXfadeDraft(null);
- }}
- />
- <ScrubValue
- label="Transition length"
- className="w-9 text-muted-foreground"
- value={xfade}
- min={0}
- max={TRANSITION_MAX}
- step={0.1}
- format={formatFade}
- parse={parseSecondsInput}
- onScrub={setXfadeDraft}
- onCommit={(v) => {
- useEditor.getState().setClipTransition(clip.id, v);
- setXfadeDraft(null);
- }}
- />
- </Row>
- </>
- )}
+ <Row label="Effects">
+ <button
+ type="button"
+ className="clip-effects flex h-8 w-[8.5rem] items-center justify-between rounded-md border border-input px-2.5 text-[11.5px] font-medium text-muted-foreground transition-colors hover:text-foreground"
+ onClick={() => setEffectsFor(clip.id)}
+ >
+ <span className="truncate">{effectsSummary(clip, hasNext)}</span>
+ <ChevronRight className="size-3.5 shrink-0" />
+ </button>
+ </Row>
{/* Audio */}
<div className="my-1.5 h-px bg-border" />
@@ -711,15 +610,14 @@ function ColorPanel({ clip, onBack }: { clip: VideoClip; onBack: () => void }) {
ck.end();
}}
/>
- {value !== 0 && (
- <ResetButton
- title={`Reset ${f.label.toLowerCase()}`}
- onClick={() => {
- setField(f.key, 0);
- ck.end();
- }}
- />
- )}
+ <ResetButton
+ title={`Reset ${f.label.toLowerCase()}`}
+ show={value !== 0}
+ onClick={() => {
+ setField(f.key, 0);
+ ck.end();
+ }}
+ />
</Row>
);
})}
@@ -959,12 +857,11 @@ function AudioPanel({ clip }: { clip: AudioClip }) {
parse={parseTimeInput}
onCommit={(v) => commitAudio({ out: v })}
/>
- {asset && (clip.in > 1e-3 || clip.out < asset.duration - 1e-3) && (
- <ResetButton
- title="Reset trim"
- onClick={() => commitAudio({ in: 0, out: asset.duration })}
- />
- )}
+ <ResetButton
+ title="Reset trim"
+ show={!!asset && (clip.in > 1e-3 || clip.out < asset.duration - 1e-3)}
+ onClick={() => asset && commitAudio({ in: 0, out: asset.duration })}
+ />
</Row>
<Row label="Starts at">
<ScrubValue
@@ -1004,9 +901,11 @@ function AudioPanel({ clip }: { clip: AudioClip }) {
onScrub={(v) => setAudio({ speed: Math.abs(v - 1) < 1e-4 ? undefined : v })}
onCommit={(v) => commitAudio({ speed: Math.abs(v - 1) < 1e-4 ? undefined : v })}
/>
- {Math.abs(speed - 1) > 1e-4 && (
- <ResetButton title="Reset speed" onClick={() => commitAudio({ speed: undefined })} />
- )}
+ <ResetButton
+ title="Reset speed"
+ show={Math.abs(speed - 1) > 1e-4}
+ onClick={() => commitAudio({ speed: undefined })}
+ />
</Row>
<Row label="Volume">
<Slider
diff --git a/site/src/cut/components/SidePanel.tsx b/site/src/cut/components/SidePanel.tsx
index dcbce867..e6f8cfa9 100644
--- a/site/src/cut/components/SidePanel.tsx
+++ b/site/src/cut/components/SidePanel.tsx
@@ -15,6 +15,7 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { SectionTitle } from "@/cut/components/SectionTitle";
+import { Slider } from "@/components/ui/slider";
import {
DropdownMenu,
DropdownMenuContent,
@@ -57,7 +58,7 @@ import {
type LibraryFolder,
} from "@/cut/lib/library";
import { revealMedia } from "@/cut/lib/media";
-import { mediaUrl, type LibraryTemplate } from "@/cut/lib/types";
+import { mediaUrl, TRANSITION_MAX, type LibraryTemplate } from "@/cut/lib/types";
import { genPulseOverlay, isGenTab, useGenNotify, useGenPulse, useWatchGenTab } from "@/cut/lib/genNotify";
import { CAPTION_LIMIT, normalizeTags } from "@/cut/lib/publish";
import { useEditor } from "@/cut/lib/store";
@@ -978,11 +979,41 @@ function CopyChip({ text, label }: { text: string; label: string }) {
);
}
+/** Whole-video fade slider (project-level: veils picture, titles, captions,
+ * and the mix at the cut's start or end). Lives here — the only
+ * project-scoped panel — since per-clip fades moved into clip Effects. */
+function ProjectFadeRow({ label, value, onChange }: {
+ label: string;
+ value: number;
+ onChange: (v: number) => void;
+}) {
+ return (
+ <label className="flex items-center justify-between gap-3 text-[12px] text-muted-foreground">
+ {label}
+ <span className="flex items-center gap-2">
+ <Slider
+ className={`project-${label.toLowerCase().replace(" ", "-")} data-horizontal:w-28`}
+ min={0}
+ max={TRANSITION_MAX}
+ step={0.1}
+ value={value}
+ onValueChange={(v) => onChange(Number(v))}
+ />
+ <span className="w-9 text-right font-mono text-[11.5px]">
+ {value < 0.05 ? "Off" : `${value.toFixed(1)}s`}
+ </span>
+ </span>
+ </label>
+ );
+}
+
function PublishPanel() {
const publish = useEditor((s) => s.publish);
const setPublish = useEditor((s) => s.setPublish);
const notes = useEditor((s) => s.notes);
const setNotes = useEditor((s) => s.setNotes);
+ const fadeIn = useEditor((s) => s.fadeIn);
+ const fadeOut = useEditor((s) => s.fadeOut);
const tagsLine = normalizeTags(publish.tags);
const combined = [publish.caption.trim(), tagsLine].filter(Boolean).join("\n\n");
const count = combined.length;
@@ -992,6 +1023,20 @@ function PublishPanel() {
<>
<PanelHead title="Details" />
<div className="flex min-h-0 flex-col gap-4 overflow-y-auto px-3.5 pb-4">
+ <div className="flex flex-col gap-1.5">
+ <SectionTitle>Video</SectionTitle>
+ <ProjectFadeRow
+ label="Fade in"
+ value={fadeIn}
+ onChange={(v) => useEditor.getState().setProjectFade({ fadeIn: v })}
+ />
+ <ProjectFadeRow
+ label="Fade out"
+ value={fadeOut}
+ onChange={(v) => useEditor.getState().setProjectFade({ fadeOut: v })}
+ />
+ </div>
+
<div className="flex flex-col gap-1.5">
<div className="flex items-center justify-between">
<SectionTitle>Caption</SectionTitle>
diff --git a/site/src/cut/components/Timeline.tsx b/site/src/cut/components/Timeline.tsx
index 4b4b55f6..fd307692 100644
--- a/site/src/cut/components/Timeline.tsx
+++ b/site/src/cut/components/Timeline.tsx
@@ -1,7 +1,7 @@
"use client";
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
-import { ArrowDownToLine, AudioLines, Blend, Check, Clapperboard, EllipsisVertical, Expand, Eye, EyeOff, FolderPlus, Loader2, Pause, Play, Scissors, SkipBack, Sunrise, Sunset, Trash2, Type, Volume2, VolumeX, ZoomIn, ZoomOut, type LucideIcon } from "lucide-react";
+import { ArrowDown, ArrowDownToLine, ArrowLeft, ArrowLeftToLine, ArrowRight, ArrowRightToLine, ArrowUp, ArrowUpToLine, AudioLines, Blend, Check, Circle, Clapperboard, Droplets, EllipsisVertical, Expand, Eye, EyeOff, FolderPlus, FoldHorizontal, Loader2, Moon, Pause, Play, Scissors, SkipBack, Sun, Target, Trash2, Type, UnfoldHorizontal, Volume2, VolumeX, type LucideIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
@@ -46,10 +46,21 @@ import { cn } from "@/lib/utils";
const TRANSITION_ICONS: Record<TransitionStyle, LucideIcon> = {
crossfade: Blend,
crosszoom: Expand,
- zoomin: ZoomIn,
- zoomout: ZoomOut,
- fadein: Sunrise,
- fadeout: Sunset,
+ dipblack: Moon,
+ dipwhite: Sun,
+ blur: Droplets,
+ pushleft: ArrowLeft,
+ pushright: ArrowRight,
+ pushup: ArrowUp,
+ pushdown: ArrowDown,
+ wipeleft: ArrowLeftToLine,
+ wiperight: ArrowRightToLine,
+ wipeup: ArrowUpToLine,
+ wipedown: ArrowDownToLine,
+ circleopen: Circle,
+ circleclose: Target,
+ splitopen: UnfoldHorizontal,
+ splitclose: FoldHorizontal,
};
const VIDEO_H = 64;