Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

del: unused components/css like Track, SubRow..

Alan Trebugeaisfd64e1b2d635
diff --git a/src/components/video-editor/timeline/Item.module.css b/src/components/video-editor/timeline/Item.module.css
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/components/video-editor/timeline/Subrow.tsx b/src/components/video-editor/timeline/Subrow.tsx
deleted file mode 100644
index e16e578d..00000000
--- a/src/components/video-editor/timeline/Subrow.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import { cn } from "@/lib/utils";
-
-interface SubrowProps {
- children: React.ReactNode;
-}
-
-export default function Subrow({ children }: SubrowProps) {
- return (
- <div
- className={cn(
- "flex items-center min-h-[24px] gap-1 px-1.5 py-0 bg-transparent rounded-md text-foreground/60",
- )}
- >
- {children}
- </div>
- );
-}
diff --git a/src/components/video-editor/timeline/Timeline.module.css b/src/components/video-editor/timeline/Timeline.module.css
deleted file mode 100644
index 88b1b49c..00000000
--- a/src/components/video-editor/timeline/Timeline.module.css
+++ /dev/null
@@ -1,28 +0,0 @@
-.scrollArea {
- scrollbar-width: thin;
- scrollbar-color: hsl(var(--foreground) / 0.25) transparent;
-}
-
-.scrollArea::-webkit-scrollbar {
- width: 8px;
- height: 8px;
- background-color: transparent;
-}
-
-.scrollArea::-webkit-scrollbar-corner {
- background-color: transparent;
-}
-
-.scrollArea::-webkit-scrollbar-thumb {
- background-color: hsl(var(--foreground) / 0.25);
- border-radius: 10px;
- border: 2px solid hsl(var(--editor-surface));
-}
-
-.scrollArea::-webkit-scrollbar-thumb:hover {
- background-color: hsl(var(--foreground) / 0.35);
-}
-
-.scrollArea::-webkit-scrollbar-thumb:active {
- background-color: hsl(var(--foreground) / 0.45);
-}
diff --git a/src/components/video-editor/timeline/Track.tsx b/src/components/video-editor/timeline/Track.tsx
deleted file mode 100644
index a732b484..00000000
--- a/src/components/video-editor/timeline/Track.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import type { RowDefinition } from "dnd-timeline";
-import { useRow } from "dnd-timeline";
-import type { CSSProperties, ReactNode } from "react";
-
-interface TrackProps extends RowDefinition {
- children: ReactNode;
- hint?: string;
- isEmpty?: boolean;
- trackStyle?: CSSProperties;
-}
-
-export default function Track({ id, children, hint, isEmpty, trackStyle }: TrackProps) {
- const { setNodeRef, rowWrapperStyle, rowStyle, rowSidebarStyle, setSidebarRef } = useRow({
- id,
- });
-
- return (
- <div
- className="group/track flex-1 overflow-hidden bg-transparent"
- style={{ ...rowWrapperStyle, marginBottom: 0, minHeight: 44, ...trackStyle }}
- >
- <div ref={setSidebarRef} style={rowSidebarStyle} />
- <div
- ref={setNodeRef}
- className="relative flex-1 overflow-hidden"
- style={{ ...rowStyle, minHeight: 44 }}
- >
- {isEmpty && hint ? (
- <div className="pointer-events-none absolute inset-0 z-10 flex items-center justify-center select-none">
- <span className="rounded-full border border-foreground/[0.05] bg-foreground/[0.02] px-2 py-0.5 text-[9px] font-medium tracking-[0.04em] text-foreground/30 uppercase">
- {hint}
- </span>
- </div>
- ) : null}
- {children}
- </div>
- </div>
- );
-}
diff --git a/src/components/video-editor/timeline/components/viewport/TimelineCanvas.tsx b/src/components/video-editor/timeline/components/viewport/TimelineCanvas.tsx
index 9499fd87..0fd077c2 100644
--- a/src/components/video-editor/timeline/components/viewport/TimelineCanvas.tsx
+++ b/src/components/video-editor/timeline/components/viewport/TimelineCanvas.tsx
@@ -8,6 +8,7 @@ import {
TIMELINE_AXIS_HEIGHT_PX,
} from "../../timelineLayout";
import type { AudioPeaksData } from "../../useAudioPeaks";
+import { isAnnotationTrackRowId, isAudioTrackRowId } from "../../core/rows";
import type { TimelineRenderItem } from "../../model/timelineModel";
import TimelineAxis from "../axis/TimelineAxis";
import PlaybackCursor from "../playhead/PlaybackCursor";
@@ -21,17 +22,13 @@ interface TimelineCanvasProps {
onSeek?: (time: number) => void;
canPlaceZoomAtMs?: (startMs: number) => boolean;
onSelectZoom?: (id: string | null) => void;
- onSelectTrim?: (id: string | null) => void;
onSelectClip?: (id: string | null) => void;
onSelectAnnotation?: (id: string | null) => void;
- onSelectSpeed?: (id: string | null) => void;
onSelectAudio?: (id: string | null) => void;
onAddZoomAtMs?: (startMs: number) => void;
selectedZoomId: string | null;
- selectedTrimId?: string | null;
selectedClipId?: string | null;
selectedAnnotationId?: string | null;
- selectedSpeedId?: string | null;
selectedAudioId?: string | null;
selectAllBlocksActive?: boolean;
onClearBlockSelection?: () => void;
@@ -47,16 +44,12 @@ export default function TimelineCanvas({
onAddZoomAtMs,
canPlaceZoomAtMs,
onSelectZoom,
- onSelectTrim,
onSelectClip,
onSelectAnnotation,
- onSelectSpeed,
onSelectAudio,
selectedZoomId,
- selectedTrimId: _selectedTrimId,
selectedClipId,
selectedAnnotationId,
- selectedSpeedId: _selectedSpeedId,
selectedAudioId,
selectAllBlocksActive = false,
onClearBlockSelection,
@@ -80,10 +73,8 @@ export default function TimelineCanvas({
if (!onSeek || videoDurationMs <= 0) return;
onSelectZoom?.(null);
- onSelectTrim?.(null);
onSelectClip?.(null);
onSelectAnnotation?.(null);
- onSelectSpeed?.(null);
onSelectAudio?.(null);
onClearBlockSelection?.();
@@ -97,10 +88,8 @@ export default function TimelineCanvas({
[
onSeek,
onSelectZoom,
- onSelectTrim,
onSelectClip,
onSelectAnnotation,
- onSelectSpeed,
onSelectAudio,
onClearBlockSelection,
videoDurationMs,
@@ -110,12 +99,15 @@ export default function TimelineCanvas({
],
);
- const audioRowIds = useMemo(
- () => new Set(items.map((item) => item.rowId)).size,
- [items],
- );
-
- const timelineRowCount = Math.max(2, audioRowIds);
+ const timelineRowCount = useMemo(() => {
+ const annotationRowIds = new Set<string>();
+ const audioRowIds = new Set<string>();
+ for (const item of items) {
+ if (isAnnotationTrackRowId(item.rowId)) annotationRowIds.add(item.rowId);
+ if (isAudioTrackRowId(item.rowId)) audioRowIds.add(item.rowId);
+ }
+ return 2 + annotationRowIds.size + audioRowIds.size;
+ }, [items]);
const timelineRowsMinHeightPx = getTimelineRowsMinHeightPx(timelineRowCount);
const timelineContentMinHeightPx = getTimelineContentMinHeightPx(timelineRowCount);
const timelineViewportStretchFactor = getTimelineViewportStretchFactor(timelineRowCount);