import React from 'react' interface Section { key: K label: string disabled?: boolean tag?: string } interface SectionRailProps { sections: Section[] active: K onSelect: (k: K) => void } export function SectionRail({ sections, active, onSelect, }: SectionRailProps): React.JSX.Element { return (
{sections.map((s) => { const isActive = s.key === active const cls = [ 'section-row', isActive ? 'active' : '', s.disabled ? 'disabled' : '', ] .filter(Boolean) .join(' ') return (
onSelect(s.key)} role={s.disabled ? undefined : 'button'} tabIndex={s.disabled ? undefined : 0} onKeyDown={ s.disabled ? undefined : (e) => { if (e.key === 'Enter' || e.key === ' ') onSelect(s.key) } } > {s.label} {s.tag != null && ( {s.tag} )}
) })}
) }