{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timeline-11",
  "title": "Horizontal timeline",
  "description": "Milestones along a horizontal line that stacks into a vertical list when the piece gets narrow.",
  "dependencies": [
    "date-fns"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/timeline.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/timeline/timeline-11.tsx",
      "content": "import {\n  Timeline,\n  TimelineContent,\n  TimelineDate,\n  TimelineHeader,\n  TimelineIndicator,\n  TimelineItem,\n  TimelineSeparator,\n  TimelineTitle,\n} from '@/registry/ndeko/ui/timeline';\n\nimport { ByWidth } from './_parts/by-width';\nimport { dayLabelOf } from './_parts/dates';\nimport { currentStepOf, stepStateOf, StepStateNote } from './_parts/step-state';\n\ntype Stage = {\n  day: string;\n  title: string;\n  note: string;\n};\n\ntype ScheduleProps = {\n  orientation: 'horizontal' | 'vertical';\n};\n\nconst BOOK_LAUNCH: Stage[] = [\n  { day: '2026-09-14', title: 'Final manuscript', note: 'Edits signed off' },\n  { day: '2026-10-05', title: 'Proofs', note: 'Two rounds read' },\n  { day: '2026-10-26', title: 'Printing', note: 'First run on press' },\n  { day: '2026-11-19', title: 'Launch night', note: 'Reading at the shop' },\n];\n\nconst DONE_COUNT = 3;\n\nconst CLOSER_ROWS_WHEN_STACKED =\n  'group-data-[orientation=vertical]/timeline:not-last:pb-6';\n\nfunction Schedule({ orientation }: ScheduleProps) {\n  return (\n    <Timeline\n      defaultValue={DONE_COUNT}\n      orientation={orientation}\n      role='list'\n      aria-label='Solway Books launch schedule'\n    >\n      {BOOK_LAUNCH.map((stage, index) => {\n        const step = index + 1;\n        const state = stepStateOf(step, DONE_COUNT);\n\n        return (\n          <TimelineItem\n            key={stage.day}\n            step={step}\n            role='listitem'\n            aria-current={currentStepOf(state)}\n            className={CLOSER_ROWS_WHEN_STACKED}\n          >\n            <TimelineHeader>\n              <TimelineIndicator />\n              <TimelineSeparator />\n              <TimelineDate dateTime={stage.day}>\n                {dayLabelOf(stage.day)}\n              </TimelineDate>\n              <TimelineTitle>\n                {stage.title}\n                <StepStateNote state={state} />\n              </TimelineTitle>\n            </TimelineHeader>\n            <TimelineContent>{stage.note}</TimelineContent>\n          </TimelineItem>\n        );\n      })}\n    </Timeline>\n  );\n}\n\nexport default function Timeline11() {\n  return (\n    <ByWidth\n      narrow={<Schedule orientation='vertical' />}\n      wide={<Schedule orientation='horizontal' />}\n    />\n  );\n}\n",
      "type": "registry:component",
      "target": "components/timeline/timeline-11.tsx"
    },
    {
      "path": "registry/ndeko/components/timeline/_parts/by-width.tsx",
      "content": "type ByWidthProps = {\n  narrow: React.ReactNode;\n  wide: React.ReactNode;\n};\n\n/*\n * A timeline takes its orientation as a prop, so a piece that lies along a line draws both and its\n * own width decides which one shows: under 576px four columns do not fit, and the list stacks.\n */\nexport function ByWidth({ narrow, wide }: ByWidthProps) {\n  return (\n    <div className='@container w-full'>\n      <div className='@xl:hidden'>{narrow}</div>\n      <div className='@max-xl:hidden'>{wide}</div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/timeline/_parts/by-width.tsx"
    },
    {
      "path": "registry/ndeko/components/timeline/_parts/dates.ts",
      "content": "import { differenceInMinutes, format, parseISO } from 'date-fns';\n\n/* Every time is read against one fixed moment and written without a time zone, so the server and the browser print the same labels. */\nconst NOW = '2026-11-12T15:00:00';\n\nconst MINUTES_PER_HOUR = 60;\n\nconst MINUTES_PER_DAY = 1440;\n\nexport function dayLabelOf(isoDay: string) {\n  const day = parseISO(isoDay);\n  return format(day, 'MMM d, yyyy');\n}\n\nexport function stampLabelOf(isoTime: string) {\n  const time = parseISO(isoTime);\n  return format(time, \"MMMM d, yyyy 'at' HH:mm\");\n}\n\nfunction agoOf(count: number, unit: string) {\n  if (count === 1) {\n    return `1 ${unit} ago`;\n  }\n  return `${count} ${unit}s ago`;\n}\n\nexport function agoLabelOf(isoTime: string) {\n  const now = parseISO(NOW);\n  const time = parseISO(isoTime);\n  const minutes = differenceInMinutes(now, time);\n  if (minutes < 1) {\n    return 'Just now';\n  }\n  if (minutes < MINUTES_PER_HOUR) {\n    return agoOf(minutes, 'minute');\n  }\n  if (minutes < MINUTES_PER_DAY) {\n    const hours = Math.floor(minutes / MINUTES_PER_HOUR);\n    return agoOf(hours, 'hour');\n  }\n  const days = Math.floor(minutes / MINUTES_PER_DAY);\n  return agoOf(days, 'day');\n}\n",
      "type": "registry:component",
      "target": "components/timeline/_parts/dates.ts"
    },
    {
      "path": "registry/ndeko/components/timeline/_parts/step-state.tsx",
      "content": "type StepState = 'done' | 'current' | 'ahead';\n\nconst STATE_WORD: Record<StepState, string> = {\n  done: 'done',\n  current: 'in progress',\n  ahead: 'to come',\n};\n\nexport function stepStateOf(step: number, doneCount: number): StepState {\n  if (step <= doneCount) {\n    return 'done';\n  }\n  if (step === doneCount + 1) {\n    return 'current';\n  }\n  return 'ahead';\n}\n\nexport function currentStepOf(state: StepState) {\n  if (state === 'current') {\n    return 'step' as const;\n  }\n  return undefined;\n}\n\ntype StepStateNoteProps = {\n  state: StepState;\n};\n\n/* The colour of the marker says where a step stands: this says it in words for a screen reader. */\nexport function StepStateNote({ state }: StepStateNoteProps) {\n  return <span className='sr-only'>, {STATE_WORD[state]}</span>;\n}\n",
      "type": "registry:component",
      "target": "components/timeline/_parts/step-state.tsx"
    }
  ],
  "categories": [
    "components",
    "timeline"
  ],
  "type": "registry:component"
}