summaryrefslogtreecommitdiff
path: root/apps/web/src/lib
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-07-08 00:07:22 +0200
committerMaze Winther <mazewinther@gmail.com>2025-07-08 00:07:22 +0200
commitd750d7f41dfdb8e3c9a2b00206657ca0c4b99098 (patch)
tree55ed1983d207f64b3f51e56845f8c4dd65b164fa /apps/web/src/lib
parent9d2fd50fbc764308b1ebad8a43fa0556e77b9937 (diff)
downloadopencut-d750d7f41dfdb8e3c9a2b00206657ca0c4b99098.tar.gz
shipping too hard
Diffstat (limited to 'apps/web/src/lib')
-rw-r--r--apps/web/src/lib/timeline-constants.ts123
1 files changed, 75 insertions, 48 deletions
diff --git a/apps/web/src/lib/timeline-constants.ts b/apps/web/src/lib/timeline-constants.ts
index fbbfe081..dd93cfdf 100644
--- a/apps/web/src/lib/timeline-constants.ts
+++ b/apps/web/src/lib/timeline-constants.ts
@@ -1,48 +1,75 @@
-import type { TrackType } from "@/types/timeline";
-
-// Track color definitions
-export const TRACK_COLORS = {
- media: {
- solid: "bg-blue-500",
- background: "bg-blue-500/20",
- border: "border-blue-500/30",
- },
- text: {
- solid: "bg-purple-500",
- background: "bg-purple-500/20",
- border: "border-purple-500/30",
- },
- audio: {
- solid: "bg-green-500",
- background: "bg-green-500/20",
- border: "border-green-500/30",
- },
- default: {
- solid: "bg-gray-500",
- background: "bg-gray-500/20",
- border: "border-gray-500/30",
- },
-} as const;
-
-// Utility functions
-export function getTrackColors(type: TrackType) {
- return TRACK_COLORS[type] || TRACK_COLORS.default;
-}
-
-export function getTrackElementClasses(type: TrackType) {
- const colors = getTrackColors(type);
- return `${colors.background} ${colors.border}`;
-}
-
-export function getTrackLabelColor(type: TrackType) {
- return getTrackColors(type).solid;
-}
-
-// Other timeline constants
-export const TIMELINE_CONSTANTS = {
- ELEMENT_MIN_WIDTH: 80,
- PIXELS_PER_SECOND: 50,
- TRACK_HEIGHT: 60,
- DEFAULT_TEXT_DURATION: 5,
- ZOOM_LEVELS: [0.25, 0.5, 1, 1.5, 2, 3, 4],
-} as const;
+import type { TrackType } from "@/types/timeline";
+
+// Track color definitions
+export const TRACK_COLORS: Record<
+ TrackType,
+ { solid: string; background: string; border: string }
+> = {
+ media: {
+ solid: "bg-blue-500",
+ background: "bg-blue-500/20",
+ border: "border-blue-500/30",
+ },
+ text: {
+ solid: "bg-[#9C4937]",
+ background: "bg-[#9C4937]",
+ border: "border-[#9C4937]/40",
+ },
+ audio: {
+ solid: "bg-green-500",
+ background: "bg-green-500/20",
+ border: "border-green-500/30",
+ },
+} as const;
+
+// Utility functions
+export function getTrackColors(type: TrackType) {
+ return TRACK_COLORS[type];
+}
+
+export function getTrackElementClasses(type: TrackType) {
+ const colors = getTrackColors(type);
+ return `${colors.background} ${colors.border}`;
+}
+
+export function getTrackLabelColor(type: TrackType) {
+ return getTrackColors(type).solid;
+}
+
+// Track height definitions
+export const TRACK_HEIGHTS: Record<TrackType, number> = {
+ media: 65,
+ text: 25,
+ audio: 50,
+} as const;
+
+// Utility function for track heights
+export function getTrackHeight(type: TrackType): number {
+ return TRACK_HEIGHTS[type];
+}
+
+// Calculate cumulative height up to (but not including) a track index
+export function getCumulativeHeightBefore(
+ tracks: Array<{ type: TrackType }>,
+ trackIndex: number
+): number {
+ return tracks
+ .slice(0, trackIndex)
+ .reduce((sum, track) => sum + getTrackHeight(track.type), 0);
+}
+
+// Calculate total height of all tracks
+export function getTotalTracksHeight(
+ tracks: Array<{ type: TrackType }>
+): number {
+ return tracks.reduce((sum, track) => sum + getTrackHeight(track.type), 0);
+}
+
+// Other timeline constants
+export const TIMELINE_CONSTANTS = {
+ ELEMENT_MIN_WIDTH: 80,
+ PIXELS_PER_SECOND: 50,
+ TRACK_HEIGHT: 60, // Default fallback
+ DEFAULT_TEXT_DURATION: 5,
+ ZOOM_LEVELS: [0.25, 0.5, 1, 1.5, 2, 3, 4],
+} as const;