import { clsx } from "clsx"; import { MONTHS_SHORT } from "./timelineConstants.js"; interface TimelineHeaderProps { monthGroups: { label: string; colCount: number }[]; dates: Date[]; CELL_WIDTH: number; LABEL_WIDTH: number; HEADER_MONTH_HEIGHT: number; HEADER_DAY_HEIGHT: number; zoom: "day" | "week" | "month"; viewMode: "resource" | "project"; today: Date; } export function TimelineHeader({ monthGroups, dates, CELL_WIDTH, LABEL_WIDTH, HEADER_MONTH_HEIGHT, HEADER_DAY_HEIGHT, zoom, viewMode, today, }: TimelineHeaderProps) { return ( <> {/* Month header */}
{monthGroups.map((m, i) => (
{m.label}
))}
{/* Day header — hidden at month zoom (cells too narrow for labels) */} {zoom !== "month" && (
{viewMode === "resource" ? "Resource" : "Project / Resource"}
{dates.map((date, i) => { const isToday = date.toDateString() === today.toDateString(); const dow = date.getDay(); const isMonday = dow === 1; const isWeekend = dow === 0 || dow === 6; // Week zoom: show label only on Mondays to avoid overcrowding const showLabel = zoom === "day" || isMonday; return (
{showLabel && ( <> {zoom === "week" ? `${date.getDate()} ${MONTHS_SHORT[date.getMonth()]}` : date.getDate()} {zoom === "day" && ( {["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"][dow]} )} )}
); })}
)} ); }