{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timeline-02",
  "description": "A launch plan as a list on a rail, with the next milestone highlighted and how soon or how late each one is.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json",
    "https://www.dashboardblocks.com/r/radix/status-label.json",
    "https://www.dashboardblocks.com/r/radix/timeline.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/timeline/timeline-02.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  BlockStateText,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { KPIValue } from '@/registry/components/dashboardblocks/kpi'\nimport {\n  StatusLabel,\n  statusToneClasses,\n} from '@/registry/components/dashboardblocks/status-label'\nimport {\n  TimelineStatusLabel,\n  type TimelineStatus,\n  formatTimelineDate,\n  getDaysBetween,\n} from '@/registry/components/dashboardblocks/timeline'\nimport { formatRelativeDays } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface Milestone {\n  /** Leave it out while a milestone has no date: the row shows none. */\n  date?: Date\n  description?: string\n  id: string\n  label: string\n  status: TimelineStatus\n}\n\ninterface Timeline2Props extends BlockStateProps {\n  /** What the milestones are for, such as a release name. */\n  description: string\n  /** Oldest first. Leave out, or pass none, to show the empty state. */\n  milestones?: Milestone[]\n  /** Pass a fixed date, so the block renders the same on the server and in the browser. */\n  now: Date\n  title: string\n}\n\nconst date = (month: number, day: number) => new Date(Date.UTC(2026, month - 1, day))\n\nconst exampleProps: Timeline2Props = {\n  description: 'Mobile app 3.0',\n  milestones: [\n    {\n      date: date(8, 3),\n      description: 'Specs and designs signed off',\n      id: 'kickoff',\n      label: 'Kickoff',\n      status: 'done',\n    },\n    {\n      date: date(9, 11),\n      description: 'Feature complete on both platforms',\n      id: 'alpha',\n      label: 'Internal alpha',\n      status: 'done',\n    },\n    {\n      date: date(10, 2),\n      description: '200 customers from the waitlist',\n      id: 'beta',\n      label: 'Public beta',\n      status: 'at-risk',\n    },\n    {\n      date: date(10, 23),\n      description: 'App Store and Play review',\n      id: 'review',\n      label: 'Store submission',\n      status: 'planned',\n    },\n    {\n      date: date(11, 4),\n      description: 'Launch post, email and in-app banner',\n      id: 'launch',\n      label: 'General availability',\n      status: 'planned',\n    },\n  ],\n  now: date(9, 26),\n  title: 'Launch milestones',\n}\n\nconst Timeline2 = (props: Timeline2Props) => {\n  const { description, milestones = [], now, errorMessage, status, title } = props\n  const state = getBlockState(status, milestones)\n  const next = milestones.find((milestone) => milestone.status !== 'done')\n  const done = milestones.filter((milestone) => milestone.status === 'done').length\n  const nextDays = next?.date ? getDaysBetween(now, next.date) : 0\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <p className='text-muted-foreground text-sm'>\n                {description}.{' '}\n                <BlockReady>\n                  {done} of {milestones.length} milestones done.\n                </BlockReady>\n              </p>\n            </header>\n            {state && (\n              <div className='flex flex-col gap-1'>\n                <KPIValue />\n                {state === 'loading' && <BlockStateText className='text-sm' />}\n              </div>\n            )}\n            {!state && next?.date && (\n              <div className='flex flex-col gap-1'>\n                <p className='text-4xl font-light tracking-tight tabular-nums'>\n                  {Math.abs(nextDays)}\n                  <span className='text-muted-foreground ml-1 text-base font-normal tracking-normal'>\n                    {Math.abs(nextDays) === 1 ? 'day' : 'days'}\n                  </span>\n                </p>\n                <p className='text-muted-foreground text-sm'>\n                  {nextDays < 0 ? (\n                    <StatusLabel variant='text' tone='bad'>\n                      Late\n                    </StatusLabel>\n                  ) : (\n                    'Until'\n                  )}{' '}\n                  {nextDays < 0 ? 'on' : ''}{' '}\n                  <span className='text-foreground font-medium'>{next.label}</span>,{' '}\n                  {nextDays < 0 ? 'due' : 'on'} {formatTimelineDate(next.date)}.\n                  {next.status === 'at-risk' && (\n                    <>\n                      {' '}\n                      <StatusLabel variant='text' tone='warning'>\n                        At risk.\n                      </StatusLabel>\n                    </>\n                  )}\n                </p>\n              </div>\n            )}\n            {state === 'loading' && (\n              <div className='border-t'>\n                <BlockStateRows rows={5} />\n              </div>\n            )}\n            {!state && (\n              <ol className='flex flex-col border-t pt-4'>\n                {milestones.map((milestone, index) => {\n                  const days = milestone.date ? getDaysBetween(now, milestone.date) : 0\n                  const isNext = milestone.id === next?.id\n                  const overdue = milestone.status !== 'done' && days < 0\n                  return (\n                    <li key={milestone.id} className='relative flex gap-3 pb-5 last:pb-0'>\n                      {index < milestones.length - 1 && (\n                        <span\n                          aria-hidden\n                          className={cn(\n                            'absolute top-6 bottom-1 left-[9px] w-px',\n                            milestone.status === 'done'\n                              ? 'bg-foreground/60'\n                              : 'border-l border-dashed',\n                          )}\n                        />\n                      )}\n                      <TimelineStatusLabel\n                        className='bg-background relative mt-0.5 self-start [&_svg]:size-5'\n                        status={milestone.status}\n                      />\n                      <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n                        <div className='flex flex-wrap items-baseline justify-between gap-x-3'>\n                          <span\n                            className={cn(\n                              'text-sm font-medium',\n                              milestone.status === 'done' && 'text-muted-foreground',\n                            )}\n                          >\n                            {milestone.label}\n                            {milestone.status === 'at-risk' && (\n                              <StatusLabel\n                                aria-hidden\n                                className='ml-2 text-xs'\n                                tone='warning'\n                              >\n                                At risk\n                              </StatusLabel>\n                            )}\n                            {isNext && (\n                              <StatusLabel className='ml-2 text-xs' tone='info'>\n                                Next\n                              </StatusLabel>\n                            )}\n                          </span>\n                          {milestone.date && (\n                            <span className='text-muted-foreground text-xs tabular-nums'>\n                              {formatTimelineDate(milestone.date)}\n                              {milestone.status !== 'done' && (\n                                <span\n                                  className={cn(\n                                    'ml-1.5',\n                                    overdue && statusToneClasses.bad,\n                                  )}\n                                >\n                                  {overdue\n                                    ? `${-days} days late`\n                                    : formatRelativeDays(days)}\n                                </span>\n                              )}\n                            </span>\n                          )}\n                        </div>\n                        {milestone.description && (\n                          <span className='text-muted-foreground text-sm'>\n                            {milestone.description}\n                          </span>\n                        )}\n                      </div>\n                    </li>\n                  )\n                })}\n              </ol>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  Timeline2,\n  exampleProps as timeline2ExampleProps,\n  type Milestone,\n  type Timeline2Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/timeline/timeline-02.tsx"
    }
  ],
  "meta": {
    "shows": "A launch plan as a list on a rail, with the next milestone highlighted and how soon or how late each one is.",
    "size": "half",
    "usedWith": [
      "timeline-01",
      "checklist-01"
    ],
    "component": "Timeline2",
    "props": "{ description: string; milestones?: { date?: Date; description?: string; id: string; label: string; status: \"done\" | \"in-progress\" | \"planned\" | \"at-risk\" }[]; now: Date; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
