'use client' import type { ReactNode } from 'react' import { InkText } from './ink' /** * The five journey stations (Företaget → Klart): dots, uppercase labels and * the inked-in answers beneath completed stations. No connecting lines. * Completed stations are jump-back buttons (plan: rewind to the station's * first question). Labels/answers hide under 640px; answers are mirrored * into a visually hidden aria-live region. */ export interface TrackStation { label: string answer?: string | null } interface JourneyTrackProps { stations: TrackStation[] /** Index of the active station (0-4). Earlier stations render as done. */ active: number onJump?: (station: number) => void /** The orb canvas (positioned absolutely inside the band). */ children?: ReactNode /** Screen-reader description of what the orb is doing. */ orbLabel?: string } const LEFTS = ['7.0%', '28.5%', '50.0%', '71.5%', '93.0%'] export default function JourneyTrack({ stations, active, onJump, children, orbLabel }: JourneyTrackProps) { return (
{stations.map((st, i) => { const done = i < active return (
onJump(i) : undefined} onKeyDown={ done && onJump ? (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() onJump(i) } } : undefined } > {st.label} {st.answer ? : null}
) })} {children} {orbLabel} {stations .filter((s) => s.answer) .map((s) => `${s.label}: ${s.answer}`) .join('. ')}
) }