import type { CategoricalIndex } from "@charcuterie/tokens" import type { ReactNode } from "react" import { CATEGORICAL_APPEARANCE_CLASS, CATEGORICAL_HOVER_CLASS, } from "../categoricalStyles.ts" import { FOCUS_RING_CLASS } from "../intentStyles.ts" import { toClassName } from "../toClassName.ts" export type ScheduleEntry = { key: string dayKey: string title: string timeLabel: string sourceLabel: string sourceMarker?: string categorical?: CategoricalIndex /** Minutes since the start of this displayed day. Null is the untimed row. */ startMinute: number | null endMinute: number | null } export const ScheduleItem = ({ item, isClipped = false, onSelect, }: { item: ScheduleEntry isClipped?: boolean onSelect?: (key: string) => void }): ReactNode => { const categorical = item.categorical ?? 1 const label = `${item.timeLabel}, ${item.title}, ${item.sourceLabel}` const content = ( <> {item.timeLabel} {item.sourceMarker ? ( ) : null} {item.title} ) const className = toClassName( "flex w-full min-w-0 flex-col gap-1 overflow-hidden rounded-md border p-2 text-start", isClipped ? "h-full" : undefined, CATEGORICAL_APPEARANCE_CLASS[categorical].soft, onSelect ? CATEGORICAL_HOVER_CLASS[categorical].soft : undefined, FOCUS_RING_CLASS, ) return onSelect ? ( ) : (
{content}
) }