Skip to content

Open source CapCut alternative.

TypeScript

feat(site): hide the timeline from its toolbar and bring it back from the canvas

David Le204519d86d51
diff --git a/site/src/cut/components/Editor.tsx b/site/src/cut/components/Editor.tsx
index 1e470ac6..957ae9dd 100644
--- a/site/src/cut/components/Editor.tsx
+++ b/site/src/cut/components/Editor.tsx
@@ -160,6 +160,7 @@ export function Editor({
const [opened, setOpened] = useState(false);
const exportOpen = useEditor((s) => s.exportOpen);
const aiOpen = useEditor((s) => s.aiOpen);
+ const timelineOpen = useEditor((s) => s.timelineOpen);
const sharedFeatures = useEditor((s) => s.sharedFeatures);
// The inspector only earns its column when the selection has a panel to
// show; otherwise (nothing selected, a subtitle cue, a transition bar — the
@@ -1195,10 +1196,12 @@ export function Editor({
</div>
{/* The strip anchors to the timeline's top edge and floats over the
row above it. */}
- <div className="relative min-w-0">
- <SpeedCurveStrip />
- <Timeline />
- </div>
+ {timelineOpen && (
+ <div className="relative min-w-0">
+ <SpeedCurveStrip />
+ <Timeline />
+ </div>
+ )}
</div>
{(!viewer || sharedFeatures?.chat) && (
<AiPanel
diff --git a/site/src/cut/components/Preview.tsx b/site/src/cut/components/Preview.tsx
index 526c4c29..871f846a 100644
--- a/site/src/cut/components/Preview.tsx
+++ b/site/src/cut/components/Preview.tsx
@@ -1,7 +1,7 @@
"use client";
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type RefObject } from "react";
-import { Check, Copy, Loader2, ZoomIn, ZoomOut } from "lucide-react";
+import { Check, Copy, Loader2, PanelTopClose, ZoomIn, ZoomOut } from "lucide-react";
import { usePlayback } from "@/cut/hooks/usePlayback";
import { startDrag } from "@/cut/lib/drag";
import { useBrushUi } from "@/cut/lib/removal/brushUi";
@@ -706,10 +706,28 @@ export function Preview() {
</div>
</div>
)}
+ <ShowTimelineButton />
</section>
);
}
+/** Sits over the canvas while the timeline is folded away and brings it back. */
+function ShowTimelineButton() {
+ const open = useEditor((s) => s.timelineOpen);
+ if (open) return null;
+ return (
+ <button
+ type="button"
+ title="Show timeline"
+ aria-label="Show timeline"
+ onClick={() => useEditor.getState().setTimelineOpen(true)}
+ className="absolute right-3 bottom-3 z-20 grid size-8 place-items-center rounded-full border bg-background/95 text-foreground shadow-md backdrop-blur hover:bg-accent"
+ >
+ <PanelTopClose className="size-4" />
+ </button>
+ );
+}
+
/**
* The camera's zoom control, in the pane's top-right corner. It appears while
* the camera moves and lingers a moment after, and holds while the picture is
diff --git a/site/src/cut/components/Timeline.tsx b/site/src/cut/components/Timeline.tsx
index 91c87d3a..c806f508 100644
--- a/site/src/cut/components/Timeline.tsx
+++ b/site/src/cut/components/Timeline.tsx
@@ -1,7 +1,7 @@
"use client";
import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
-import { ArrowDownToLine, AudioLines, Check, Clapperboard, Copy, Diamond, Download, EllipsisVertical, Eye, EyeOff, FolderOpen, FolderPlus, Fullscreen, Loader2, MoreHorizontal, Pause, Play, Scissors, SkipBack, Sticker, Trash2, Type, Volume2, VolumeX } from "lucide-react";
+import { ArrowDownToLine, AudioLines, Check, Clapperboard, Copy, Diamond, Download, EllipsisVertical, Eye, EyeOff, FolderOpen, FolderPlus, Fullscreen, Loader2, MoreHorizontal, PanelBottomClose, Pause, Play, Scissors, SkipBack, Sticker, Trash2, Type, Volume2, VolumeX } from "lucide-react";
import { EFFECT_CHIP_ICONS, effectIconKind, SHAPE_CHIP_ICONS, TRANSITION_ICONS } from "@/cut/components/entityIcons";
import { Button } from "@/components/ui/button";
import { GuidesMenu } from "@/cut/components/GuidesMenu";
@@ -2295,6 +2295,7 @@ export function Timeline() {
<Button variant="ghost" size="sm" title="Fit timeline to window" onClick={fit}>
Fit
</Button>
+ <HideTimelineButton />
</div>
{barTight && <GuidesMenu />}
{barTight && (
@@ -3506,11 +3507,31 @@ function TimelineToolsMenu({
Fit
</Button>
</div>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={() => useEditor.getState().setTimelineOpen(false)}>
+ <PanelBottomClose /> Hide timeline
+ </DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
}
+/** Folds the timeline away under the preview; the button over the canvas
+ * brings it back. */
+function HideTimelineButton() {
+ return (
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ aria-label="Hide timeline"
+ title="Hide timeline"
+ onClick={() => useEditor.getState().setTimelineOpen(false)}
+ >
+ <PanelBottomClose />
+ </Button>
+ );
+}
+
/** Saving the selection as a template: the state behind both the toolbar
* button and the menu row that replaces it. */
function useSaveSelection() {
diff --git a/site/src/cut/lib/store.ts b/site/src/cut/lib/store.ts
index 158d9309..895e7b64 100644
--- a/site/src/cut/lib/store.ts
+++ b/site/src/cut/lib/store.ts
@@ -396,6 +396,9 @@ export interface EditorState {
/** Whether the settings panel shows its body beside its tab rail. Hiding it
* holds across sessions and selections: only the rail brings it back. */
inspectorOpen: boolean;
+ /** Whether the timeline shows under the preview. Hiding it holds across
+ * sessions; a button over the canvas brings it back. */
+ timelineOpen: boolean;
/** In-progress or finished brief-to-video run; persisted on ProjectDoc.genvideo
* and driven by the genScene store. Absent when no scene was generated. */
genvideo?: VideoProject;
@@ -827,6 +830,7 @@ export interface EditorState {
setDropActive: (v: "media" | "other" | null) => void;
setAiOpen: (v: boolean) => void;
setInspectorOpen: (v: boolean) => void;
+ setTimelineOpen: (v: boolean) => void;
undo: () => void;
redo: () => void;
upsertRender: (r: RenderRecord) => void;
@@ -1807,6 +1811,7 @@ export const useEditor = create<EditorState>((baseSet, get, api) => {
dropActive: null,
aiOpen: typeof window !== "undefined" && localStorage.getItem("cut-ai-open") === "1",
inspectorOpen: typeof window === "undefined" || localStorage.getItem("cut-inspector-open") !== "0",
+ timelineOpen: typeof window === "undefined" || localStorage.getItem("cut-timeline-open") !== "0",
genvideo: undefined,
renders: [],
@@ -5008,6 +5013,14 @@ export const useEditor = create<EditorState>((baseSet, get, api) => {
// View preference only.
}
},
+ setTimelineOpen: (v) => {
+ set({ timelineOpen: v });
+ try {
+ localStorage.setItem("cut-timeline-open", v ? "1" : "0");
+ } catch {
+ // View preference only.
+ }
+ },
copySelection: () => {
const s = get();