{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timeline-06",
  "title": "Timeline with icons",
  "description": "Each event has its own icon in a circle that fills once the event is done.",
  "dependencies": [
    "date-fns"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/timeline.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/timeline/timeline-06.tsx",
      "content": "import {\n  BoxIcon,\n  HomeIcon,\n  ReceiptIcon,\n  RouteIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport {\n  Timeline,\n  TimelineContent,\n  TimelineHeader,\n  TimelineIndicator,\n  TimelineItem,\n  TimelineSeparator,\n  TimelineTitle,\n} from '@/registry/ndeko/ui/timeline';\n\nimport { AgoTime } from './_parts/ago-time';\nimport { MARKER, MARKER_RAIL, MARKER_ROW } from './_parts/markers';\nimport { currentStepOf, stepStateOf, StepStateNote } from './_parts/step-state';\n\ntype OrderEvent = {\n  title: string;\n  detail: string;\n  icon: Icon;\n  at?: string;\n};\n\nconst ORDER: OrderEvent[] = [\n  {\n    title: 'Order placed',\n    detail:\n      'Order OF-20931: two bags of oat granola and a tin of cocoa, 31.50 EUR.',\n    icon: ReceiptIcon,\n    at: '2026-11-11T13:00:00',\n  },\n  {\n    title: 'Packed',\n    detail: 'Packed in the Oatfield kitchen and sealed in a paper box.',\n    icon: BoxIcon,\n    at: '2026-11-11T19:00:00',\n  },\n  {\n    title: 'Out for delivery',\n    detail: 'On the van since this afternoon, eleven stops before yours.',\n    icon: RouteIcon,\n    at: '2026-11-12T14:10:00',\n  },\n  {\n    title: 'Delivered',\n    detail:\n      'Expected today between 15:30 and 17:30, left with a neighbour if nobody is in.',\n    icon: HomeIcon,\n  },\n];\n\nconst DONE_COUNT = 3;\n\nconst ICON_TILE = [\n  MARKER,\n  'bg-foreground/[0.06] text-muted-foreground scale-90 border-none',\n  'group-data-completed/timeline-item:bg-primary group-data-completed/timeline-item:text-primary-foreground group-data-completed/timeline-item:scale-100',\n].join(' ');\n\nexport default function Timeline06() {\n  return (\n    <Timeline\n      defaultValue={DONE_COUNT}\n      role='list'\n      aria-label='Oatfield order OF-20931'\n      className='[--marker:1.5rem]'\n    >\n      {ORDER.map((orderEvent, index) => {\n        const step = index + 1;\n        const state = stepStateOf(step, DONE_COUNT);\n\n        return (\n          <TimelineItem\n            key={orderEvent.title}\n            step={step}\n            role='listitem'\n            aria-current={currentStepOf(state)}\n            className={MARKER_ROW}\n          >\n            <TimelineHeader>\n              <TimelineIndicator className={ICON_TILE}>\n                <orderEvent.icon className='size-3.5' />\n              </TimelineIndicator>\n              <TimelineSeparator className={MARKER_RAIL} />\n              <TimelineTitle className='mt-0.5'>\n                {orderEvent.title}\n                <StepStateNote state={state} />\n              </TimelineTitle>\n            </TimelineHeader>\n            <TimelineContent>\n              {orderEvent.detail}\n              {orderEvent.at && <AgoTime at={orderEvent.at} className='mt-2' />}\n            </TimelineContent>\n          </TimelineItem>\n        );\n      })}\n    </Timeline>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/timeline/timeline-06.tsx"
    },
    {
      "path": "registry/ndeko/components/timeline/_parts/ago-time.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\nimport { TimelineDate } from '@/registry/ndeko/ui/timeline';\n\nimport { agoLabelOf, stampLabelOf } from './dates';\n\ntype AgoTimeProps = {\n  at: string;\n  className?: string;\n};\n\nexport function AgoTime({ at, className }: AgoTimeProps) {\n  return (\n    <TimelineDate\n      dateTime={at}\n      title={stampLabelOf(at)}\n      className={cn('mb-0', className)}\n    >\n      {agoLabelOf(at)}\n    </TimelineDate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/timeline/_parts/ago-time.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"
}