From bd9ec023eefc4b5d26fa8b66c4338e97104f0f96 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Wed, 1 Apr 2026 19:27:49 +0200 Subject: refactor: split constants by domain and isolate timeline panel from core --- .../components/editor/panels/timeline/index.tsx | 50 ++++++++++++++-------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'apps/web/src/components/editor/panels/timeline/index.tsx') diff --git a/apps/web/src/components/editor/panels/timeline/index.tsx b/apps/web/src/components/editor/panels/timeline/index.tsx index 819413e6..4114ae2c 100644 --- a/apps/web/src/components/editor/panels/timeline/index.tsx +++ b/apps/web/src/components/editor/panels/timeline/index.tsx @@ -38,20 +38,26 @@ import { SnapIndicator } from "./snap-indicator"; import type { SnapPoint } from "@/lib/timeline/snap-utils"; import type { TimelineTrack } from "@/lib/timeline"; import { - TIMELINE_CONSTANTS, - TRACK_GAP, TIMELINE_SCROLLBAR_SIZE_PX, -} from "@/constants/timeline-constants"; + TIMELINE_CONTENT_TOP_PADDING_PX, + TIMELINE_TRACK_GAP_PX, + TIMELINE_TRACK_LABELS_COLUMN_WIDTH_PX, +} from "./layout"; import { useElementInteraction } from "@/hooks/timeline/element/use-element-interaction"; import { - getTrackHeight, - getCumulativeHeightBefore, - getTotalTracksHeight, - canTracktHaveAudio, + canTrackHaveAudio, canTrackBeHidden, getTimelineZoomMin, getTimelinePaddingPx, } from "@/lib/timeline"; +import { BASE_TIMELINE_PIXELS_PER_SECOND } from "@/lib/timeline/scale"; +import { + getTrackHeight, + getCumulativeHeightBefore, + getTotalTracksHeight, +} from "./track-layout"; +import { SELECTED_TRACK_ROW_CLASS } from "./theme"; +import { TIMELINE_HORIZONTAL_WHEEL_STEP_PX } from "./interaction"; import { isMainTrack } from "@/lib/timeline/placement"; import { TimelineToolbar } from "./timeline-toolbar"; import { useElementSelection } from "@/hooks/timeline/element/use-element-selection"; @@ -67,7 +73,7 @@ import { useEditor } from "@/hooks/use-editor"; import { useTimelinePlayhead } from "@/hooks/timeline/use-timeline-playhead"; import { DragLine } from "./drag-line"; import { invokeAction } from "@/lib/actions"; -import { resolveTimelineElementIntersections } from "@/lib/timeline/selection-hit-testing"; +import { resolveTimelineElementIntersections } from "./selection-hit-testing"; import { cn } from "@/utils/ui"; const TRACKS_CONTAINER_MAX_HEIGHT = 800; @@ -230,7 +236,7 @@ export function Timeline() { Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY; const clamped = Math.sign(raw) * - Math.min(Math.abs(raw), TIMELINE_CONSTANTS.HORIZONTAL_WHEEL_STEP_PX); + Math.min(Math.abs(raw), TIMELINE_HORIZONTAL_WHEEL_STEP_PX); tracks.scrollLeft = Math.max(0, tracks.scrollLeft + clamped); } else { tracks.scrollTop = Math.max(0, tracks.scrollTop + e.deltaY); @@ -335,7 +341,7 @@ export function Timeline() { const containerWidth = tracksContainerRef.current?.clientWidth || FALLBACK_CONTAINER_WIDTH; const contentWidth = - timelineDuration * TIMELINE_CONSTANTS.PIXELS_PER_SECOND * zoomLevel; + timelineDuration * BASE_TIMELINE_PIXELS_PER_SECOND * zoomLevel; const paddingPx = getTimelinePaddingPx({ containerWidth, zoomLevel, @@ -383,7 +389,7 @@ export function Timeline() { const timelineHeaderHeight = (timelineHeaderRef.current?.getBoundingClientRect().height ?? 0) + - TIMELINE_CONSTANTS.PADDING_TOP_PX || 0; + TIMELINE_CONTENT_TOP_PADDING_PX || 0; return (
{ @@ -577,7 +583,10 @@ function TrackLabelsPanel({ ); return ( -
+
{tracks.length > 0 && ( -
+
{tracks.map((track) => (
- {canTracktHaveAudio(track) && ( + {canTrackHaveAudio(track) && ( @@ -753,7 +765,7 @@ function TimelineTrackRows({ timeline.toggleTrackMute({ trackId: track.id }); }} > - {canTracktHaveAudio(track) && track.muted + {canTrackHaveAudio(track) && track.muted ? "Unmute track" : "Mute track"} -- cgit v1.3.1