import type { TimelineTheme } from "./timelineTheme"; import { GUTTER } from "./timelineLayout"; import type { StackingTimelineLayer, TimelineLayerId } from "./timelineTrackOrder"; export const TIMELINE_LAYER_GROUP_HEADER_H = 18; export function shouldShowTimelineLayerGroupHeader( contextKey: string, previousContextKey: string, ): boolean { return contextKey !== "" && contextKey !== previousContextKey; } export function getTimelineLayerGroupHeaderTotalHeight( layerOrder: readonly TimelineLayerId[], layers: readonly StackingTimelineLayer[], ): number { const layerById = new Map(); for (const layer of layers) layerById.set(layer.id, layer); let previousContextKey = ""; let count = 0; for (const layerId of layerOrder) { const contextKey = layerById.get(layerId)?.contextKey ?? ""; if (shouldShowTimelineLayerGroupHeader(contextKey, previousContextKey)) count += 1; previousContextKey = contextKey; } return count * TIMELINE_LAYER_GROUP_HEADER_H; } interface TimelineLayerGroupHeaderProps { contextKey: string; trackContentWidth: number; theme: TimelineTheme; accentColor: string; } export function TimelineLayerGroupHeader({ contextKey, trackContentWidth, theme, accentColor, }: TimelineLayerGroupHeaderProps) { return (
Inside: {contextKey}
); }