{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timeline-05",
  "title": "Checked timeline",
  "description": "Marking the next step done draws its check in a filled circle, fills the line to it and rolls the count.",
  "dependencies": [
    "date-fns"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/timeline.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/timeline/timeline-05.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { WordRoll } from '@/components/core/word-roll';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport {\n  Timeline,\n  TimelineContent,\n  TimelineDate,\n  TimelineHeader,\n  TimelineIndicator,\n  TimelineItem,\n  TimelineSeparator,\n  TimelineTitle,\n} from '@/registry/ndeko/ui/timeline';\n\nimport { dayLabelOf } from './_parts/dates';\nimport { MARKER, MARKER_RAIL, MARKER_ROW } from './_parts/markers';\nimport { currentStepOf, stepStateOf, StepStateNote } from './_parts/step-state';\n\ntype OnboardingStep = {\n  day: string;\n  title: string;\n  detail: string;\n};\n\nconst FIRST_WEEK: OnboardingStep[] = [\n  {\n    day: '2026-11-09',\n    title: 'Laptop and accounts',\n    detail: 'Collect your laptop and sign in to mail, chat and the tracker.',\n  },\n  {\n    day: '2026-11-10',\n    title: 'Ship a small fix',\n    detail: 'Pick a starter issue and take it through review with your buddy.',\n  },\n  {\n    day: '2026-11-12',\n    title: 'Sit in on a client call',\n    detail: 'Join the Oatfield weekly and write up the notes.',\n  },\n  {\n    day: '2026-11-13',\n    title: 'First week review',\n    detail:\n      'Thirty minutes with your lead on what worked and what was missing.',\n  },\n];\n\nconst DONE_AT_START = 2;\n\nconst CIRCLE = [\n  MARKER,\n  'text-primary-foreground scale-90 group-aria-[current=step]/timeline-item:border-foreground/40',\n  'group-data-completed/timeline-item:bg-primary group-data-completed/timeline-item:scale-100',\n].join(' ');\n\n/* The stroke is one dash as long as the path: sliding it into place draws the check, and it leaves faster than it came. */\nconst CHECK_STROKE = [\n  'opacity-0 transition-[stroke-dashoffset,opacity] duration-150 ease-(--ease-out-strong) [stroke-dasharray:1] [stroke-dashoffset:1]',\n  'group-data-completed/timeline-item:opacity-100 group-data-completed/timeline-item:delay-100 group-data-completed/timeline-item:duration-300 group-data-completed/timeline-item:[stroke-dashoffset:0]',\n].join(' ');\n\nfunction DrawnCheck() {\n  return (\n    <svg viewBox='0 0 12 12' aria-hidden='true' className='size-3.5'>\n      <path\n        d='M2.75 6.25 5 8.5l4.25-4.75'\n        pathLength={1}\n        fill='none'\n        stroke='currentColor'\n        strokeWidth='1.75'\n        strokeLinecap='round'\n        strokeLinejoin='round'\n        className={CHECK_STROKE}\n      />\n    </svg>\n  );\n}\n\nfunction progressLabelOf(doneCount: number) {\n  return `${doneCount} of ${FIRST_WEEK.length} steps done`;\n}\n\nfunction actionLabelOf(isComplete: boolean) {\n  if (isComplete) {\n    return 'Start over';\n  }\n  return 'Mark next step done';\n}\n\nexport default function Timeline05() {\n  const [doneCount, setDoneCount] = useState(DONE_AT_START);\n  const [notice, setNotice] = useState('');\n  const isComplete = doneCount === FIRST_WEEK.length;\n  const progressLabel = progressLabelOf(doneCount);\n  const actionLabel = actionLabelOf(isComplete);\n\n  function advance() {\n    if (isComplete) {\n      setDoneCount(0);\n      setNotice('Checklist cleared');\n      return;\n    }\n    const finished = FIRST_WEEK[doneCount];\n    const nextCount = doneCount + 1;\n    const nextProgress = progressLabelOf(nextCount);\n    setDoneCount(nextCount);\n    setNotice(`${finished.title} done. ${nextProgress}`);\n  }\n\n  return (\n    <div className='relative flex w-full max-w-md flex-col gap-4'>\n      <Timeline\n        value={doneCount}\n        role='list'\n        aria-label='Your first week at Mossline'\n        className='[--marker:1.5rem]'\n      >\n        {FIRST_WEEK.map((onboardingStep, index) => {\n          const step = index + 1;\n          const state = stepStateOf(step, doneCount);\n\n          return (\n            <TimelineItem\n              key={onboardingStep.title}\n              step={step}\n              role='listitem'\n              aria-current={currentStepOf(state)}\n              className={MARKER_ROW}\n            >\n              <TimelineHeader>\n                <TimelineIndicator className={CIRCLE}>\n                  <DrawnCheck />\n                </TimelineIndicator>\n                <TimelineSeparator className={MARKER_RAIL} />\n                <TimelineDate dateTime={onboardingStep.day} className='mt-1'>\n                  {dayLabelOf(onboardingStep.day)}\n                </TimelineDate>\n                <TimelineTitle>\n                  {onboardingStep.title}\n                  <StepStateNote state={state} />\n                </TimelineTitle>\n              </TimelineHeader>\n              <TimelineContent>{onboardingStep.detail}</TimelineContent>\n            </TimelineItem>\n          );\n        })}\n      </Timeline>\n      <div className='flex flex-wrap items-center justify-between gap-x-3 gap-y-2'>\n        <p className='text-muted-foreground text-xs tabular-nums'>\n          <WordRoll text={progressLabel} value={doneCount} />\n        </p>\n        <Button type='button' variant='outline' size='sm' onClick={advance}>\n          <WordRoll text={actionLabel} />\n        </Button>\n      </div>\n      <LiveRegion message={notice} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/timeline/timeline-05.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/markers.ts",
      "content": "/*\n * A marker wider than the 16px dot. Its size is --marker, set on the timeline: the row, the marker\n * and the rail are all placed from it, so the marker keeps its left edge on the edge of the piece.\n */\nexport const MARKER_ROW =\n  'group-data-[orientation=vertical]/timeline:ms-[calc(var(--marker)_+_1rem)]';\n\nexport const MARKER = [\n  'flex size-(--marker) items-center justify-center',\n  'group-data-[orientation=vertical]/timeline:-left-[calc(var(--marker)/2_+_1rem)]',\n].join(' ');\n\nexport const MARKER_RAIL = [\n  'group-data-[orientation=vertical]/timeline:-left-[calc(var(--marker)/2_+_1rem)]',\n  'group-data-[orientation=vertical]/timeline:h-[calc(100%_-_var(--marker)_-_0.25rem)]',\n  'group-data-[orientation=vertical]/timeline:translate-y-[calc(var(--marker)_+_0.125rem)]',\n].join(' ');\n",
      "type": "registry:component",
      "target": "components/timeline/_parts/markers.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"
}