import type { CSSProperties, KeyboardEvent, ReactNode } from 'react' import { Icon } from './icons' export { seriesColorForModel } from '../lib/modelSeries' /** * A `.li` list row: optional rank `.no`, optional model series `.mdot`, a * title + sub line `.lx`, an optional right-aligned `.val`. When `onClick` is * provided the row becomes a keyboard-operable button and shows the trailing * chevron; without it the row is inert and the chevron is omitted (honest). * Pass `expanded` on an interactive row to reflect its open/closed state * (`aria-expanded`, which also rotates the chevron). */ export function ListRow({ no, dotColor, title, sub, value, valueClass, onClick, expanded, }: { no?: ReactNode dotColor?: string title: ReactNode sub?: ReactNode value?: ReactNode valueClass?: string onClick?: () => void expanded?: boolean }) { const dot: CSSProperties | undefined = dotColor ? { background: dotColor } : undefined const interactive = onClick !== undefined const onKeyDown = interactive ? (event: KeyboardEvent) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault() onClick() } } : undefined return (
{no !== undefined && {no}} {dotColor !== undefined && }
{title} {sub !== undefined && {sub}}
{value !== undefined && {value}} {interactive && }
) }