From b474ad6b151d00a7bb4cdd6701c8e9ce13d752e8 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Mon, 30 Jun 2025 23:23:18 +0200 Subject: [PATCH] feat: hide preview canvas when nothing in timeline --- .../src/components/editor/preview-panel.tsx | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/apps/web/src/components/editor/preview-panel.tsx b/apps/web/src/components/editor/preview-panel.tsx index 0669292..0c26948 100644 --- a/apps/web/src/components/editor/preview-panel.tsx +++ b/apps/web/src/components/editor/preview-panel.tsx @@ -117,6 +117,9 @@ export function PreviewPanel() { const activeClips = getActiveClips(); + // Check if there are any clips in the timeline at all + const hasAnyClips = tracks.some((track) => track.clips.length > 0); + // Render a clip const renderClip = (clipData: ActiveClip, index: number) => { const { clip, mediaItem } = clipData; @@ -230,26 +233,26 @@ export function PreviewPanel() { ref={containerRef} className="flex-1 flex flex-col items-center justify-center p-3 min-h-0 min-w-0 gap-4" > -
- {activeClips.length === 0 ? ( -
- {tracks.length === 0 - ? "No media added to timeline" - : "No clips at current time"} -
- ) : ( - activeClips.map((clipData, index) => renderClip(clipData, index)) - )} -
+ {hasAnyClips && ( +
+ {activeClips.length === 0 ? ( +
+ No clips at current time +
+ ) : ( + activeClips.map((clipData, index) => renderClip(clipData, index)) + )} +
+ )} - + {hasAnyClips && } );