{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timeline",
  "type": "registry:ui",
  "title": "Timeline",
  "description": "A short record in date order: each event has a date, a title, what was said or done, and where that comes from. In a wide column the events sit side by side on a horizontal rule; in a narrow one they stack down a vertical rule. The switch keys on the…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "blog",
    "pattern"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/patterns/timeline.tsx",
      "target": "components/ui/patterns/timeline.tsx",
      "type": "registry:ui",
      "content": "import * as React from \"react\";\n\n// @interlace/timeline v1.1.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/timeline\n// What changed since: https://ds.interlace.tools/c/timeline#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — Timeline\n *\n * A short record in date order: each event has a date, a title, what was\n * said or done, and where that comes from. In a wide column the events sit\n * side by side on a horizontal rule; in a narrow one they stack down a\n * vertical rule. The switch keys on the timeline's own width (a container\n * query), not the viewport, so it is right in a sidebar too.\n *\n * For a dense, filterable map of many dated items, use `TimelineMap`. This\n * one is for a handful of events a reader reads in full.\n *\n * ## Orientation\n *\n * | `orientation` | Layout                                                 |\n * | ------------- | ------------------------------------------------------ |\n * | `responsive`  | Vertical, then rows once the timeline is 48rem wide    |\n * | `vertical`    | Always vertical                                         |\n *\n * There is no always-horizontal option: six columns at 320px cannot be read.\n * Nor does a wide timeline squeeze every event into one row: each column is\n * at least 13rem, so seven events in a 64rem column sit four and three, each\n * row on its own rule, instead of seven cramped strips.\n *\n * ## Markers\n *\n * `marker=\"accent\"` fills one event's dot in the highlight colour. The dot is\n * decoration: say in the title or the text why that event stands out.\n *\n * ## Anatomy\n *\n *   Timeline                    (div — data-slot=\"timeline\", the size container)\n *     └─ ol                     (data-slot=\"timeline-list\", data-orientation; the vertical rule is its ::before)\n *         └─ TimelineItem × n   (li — data-marker; in rows, each draws its stretch of rule as ::after)\n *             ├─ dot            (span, aria-hidden)\n *             ├─ date           (p — large, in the heading font)\n *             ├─ title          (p — bold)\n *             ├─ children       (div — the quote or the event in words)\n *             └─ source         (p — small, muted)\n *\n * ## MIN_VIEWPORT — 320\n *\n * Vertical below 48rem of its own width; text wraps.\n *\n * | Rule | Concept                 | Where in this file                                          |\n * | ---- | ----------------------- | ----------------------------------------------------------- |\n * | R4   | Extends native el       | `ol` / `li` props                                           |\n * | R6   | data-slot per part      | timeline / -list / -item / -dot / -date / -title / -body / -source |\n * | R7   | cn + ...rest            | `cn(…, className)` + `{...props}`                           |\n * | R8   | Enums, not booleans     | `orientation`, `marker`                                     |\n * | R14  | Declares min viewport   | `data-min-viewport` on the root + exported const            |\n * | R19  | Tokens only             | `border-primary`, `bg-background`, `bg-highlight`           |\n * | R25  | Server component        | No hooks; the layout is container queries in CSS            |\n * | R26  | A11y from native el     | An ordered list in date order; the dot is hidden            |\n */\n\nimport { cn } from \"@/lib/utils\";\n\nexport const MIN_VIEWPORT = 320 as const;\n\nexport type TimelineOrientation = \"responsive\" | \"vertical\";\nexport type TimelineMarker = \"default\" | \"accent\";\n\ntype TimelineProps = React.ComponentProps<\"ol\"> & {\n  /** Rows in a wide column (each column at least 13rem), or always stacked. @default 'responsive' */\n  orientation?: TimelineOrientation;\n};\n\n/*\n * Every horizontal rule below is `@3xl/timeline:`. Only a responsive\n * timeline names its wrapper `timeline` as a container, so a vertical one\n * never matches them and needs no classes of its own.\n */\nfunction Timeline({\n  orientation = \"responsive\",\n  className,\n  ...props\n}: TimelineProps) {\n  return (\n    <div\n      data-slot=\"timeline\"\n      data-min-viewport={String(MIN_VIEWPORT)}\n      className={cn(orientation === \"responsive\" && \"@container/timeline\")}\n    >\n      <ol\n        data-slot=\"timeline-list\"\n        data-orientation={orientation}\n        className={cn(\n          \"relative grid gap-1.5\",\n          // The rule: down the dots' centre line, then across it.\n          \"before:border-primary before:absolute before:inset-y-0 before:start-2 before:border-s-[3px] before:content-['']\",\n          // Rows of columns at least 13rem wide, wrapping when more do not fit.\n          // Each item draws its own stretch of the rule, so a wrapped row has\n          // one too; the stretch into the gap is clipped at the row's edge.\n          \"@3xl/timeline:grid-cols-[repeat(auto-fit,minmax(13rem,1fr))] @3xl/timeline:gap-x-4 @3xl/timeline:gap-y-8\",\n          \"@3xl/timeline:overflow-x-clip @3xl/timeline:before:hidden\",\n          className,\n        )}\n        {...props}\n      />\n    </div>\n  );\n}\n\nconst DOT: Record<TimelineMarker, string> = {\n  default: \"border-primary bg-background\",\n  accent: \"border-highlight bg-highlight\",\n};\n\ntype TimelineItemProps = Omit<React.ComponentProps<\"li\">, \"title\"> & {\n  /** When it happened: \"1968\", or a `<time>`. Always shown. */\n  date: React.ReactNode;\n  /** Who or what: \"Council vote\". */\n  title?: React.ReactNode;\n  /** Where the words come from: \"City archive, minutes\". */\n  source?: React.ReactNode;\n  /** The dot. `accent` marks the one event the page is about. @default 'default' */\n  marker?: TimelineMarker;\n};\n\nfunction TimelineItem({\n  date,\n  title,\n  source,\n  marker = \"default\",\n  className,\n  children,\n  ...props\n}: TimelineItemProps) {\n  return (\n    <li\n      data-slot=\"timeline-item\"\n      data-marker={marker}\n      className={cn(\n        \"relative min-w-0 ps-9 pb-5\",\n        \"@3xl/timeline:ps-0 @3xl/timeline:pt-10 @3xl/timeline:pb-0\",\n        // This item's stretch of the rule, reaching across the gap to the next.\n        \"@3xl/timeline:after:border-primary @3xl/timeline:after:absolute @3xl/timeline:after:start-0 @3xl/timeline:after:-end-4 @3xl/timeline:after:top-[0.9375rem] @3xl/timeline:after:border-t-[3px] @3xl/timeline:after:content-['']\",\n        \"@3xl/timeline:last:after:end-0\",\n        className,\n      )}\n      {...props}\n    >\n      <span\n        aria-hidden\n        data-slot=\"timeline-dot\"\n        className={cn(\n          \"absolute start-px top-1 z-raised size-[1.125rem] rounded-full border-4\",\n          \"@3xl/timeline:top-[0.4375rem] @3xl/timeline:start-0\",\n          DOT[marker],\n        )}\n      />\n      <p\n        data-slot=\"timeline-date\"\n        className=\"font-heading text-primary text-2xl leading-none font-extrabold\"\n      >\n        {date}\n      </p>\n      {title ? (\n        <p data-slot=\"timeline-title\" className=\"mt-1.5 text-sm font-bold\">\n          {title}\n        </p>\n      ) : null}\n      {children ? (\n        <div\n          data-slot=\"timeline-body\"\n          className=\"text-foreground mt-2 text-sm leading-relaxed\"\n        >\n          {children}\n        </div>\n      ) : null}\n      {source ? (\n        <p\n          data-slot=\"timeline-source\"\n          className=\"text-muted-foreground mt-2 text-xs\"\n        >\n          {source}\n        </p>\n      ) : null}\n    </li>\n  );\n}\n\nconst TimelineWithItem = Object.assign(Timeline, { Item: TimelineItem });\n\nexport { TimelineWithItem as Timeline, TimelineItem };\nexport type { TimelineProps, TimelineItemProps };\n"
    }
  ],
  "meta": {
    "tier": "pattern",
    "client": false,
    "minViewport": 320,
    "loading": false,
    "version": "1.1.0",
    "since": "2.0.0"
  },
  "docs": "## @interlace/timeline\n\nInstalled to `components/ui/patterns/timeline.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/patterns/timeline';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/timeline\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
