{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timeline",
  "title": "Timeline",
  "author": "AlgorizeTech",
  "description": "Ask the user to pick one of 5 timeline variants: https://avaraui.com/view/timeline. This item holds 5 of them as looks of one component (left, center, right, minimal, glass). Skip the question if the user already named one. A vertical event timeline with status states, icons and GSAP scroll reveal. Use it for order tracking and process status where each step is done, current or upcoming.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/blocks/TimelineBlock.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { ChevronDown } from \"lucide-react\";\nimport React, { forwardRef, useEffect, useRef, useState } from \"react\";\nimport { getThemeStyles } from \"./timeline-theme\";\n\n// ==========================================\n// THEME & CONFIGURATION\n// ==========================================\nexport type TimelineColor =\n  | \"indigo\"\n  | \"rose\"\n  | \"emerald\"\n  | \"zinc\"\n  | (string & {});\nexport type TimelineVariant = \"default\" | \"glass\" | \"minimal\";\nexport type TimelineLayout = \"left\" | \"center\" | \"right\";\n\n/** GSAP's power3.out, sampled into a CSS `linear()` curve. */\nconst EASE_POWER3_OUT =\n  \"linear(0, .0963, .1855, .2679, .3439, .4138, .478, .5367, .5904, .6392, .6836, .7237, .7599, .7924, .8215, .8474, .8704, .8907, .9085, .924, .9375, .9491, .959, .9674, .9744, .9802, .985, .9888, .9919, .9943, .9961, .9974, .9984, .9991, .9995, .9998, .9999, 1, 1, 1, 1)\";\n\n// ==========================================\n// INTERFACES\n// ==========================================\nexport type TimelineStatus =\n  | \"completed\"\n  | \"current\"\n  | \"upcoming\"\n  | (string & {});\n\nexport interface TimelineItemType {\n  id: string | number;\n  title: string;\n  date: string;\n  description?: string;\n  icon?: React.ElementType;\n  content?: React.ReactNode;\n  action?: React.ReactNode; // e.g., a button\n  status?: TimelineStatus;\n}\n\nexport interface TimelineBlockProps\n  extends React.HTMLAttributes<HTMLDivElement> {\n  items: TimelineItemType[];\n  color?: TimelineColor;\n  variant?: TimelineVariant;\n  layout?: TimelineLayout;\n  animate?: boolean;\n}\n\n// ==========================================\n// MAIN COMPONENT\n// ==========================================\nexport const TimelineBlock = forwardRef<HTMLDivElement, TimelineBlockProps>(\n  (\n    {\n      items,\n      color = \"primary\",\n      variant = \"default\",\n      layout = \"left\",\n      animate = true,\n      className,\n      ...props\n    },\n    ref,\n  ) => {\n    const { theme, style } = getThemeStyles(color as string);\n    const containerRef = useRef<HTMLDivElement>(null);\n\n    useEffect(() => {\n      if (!animate || !containerRef.current) return;\n      const elements = containerRef.current.querySelectorAll<HTMLElement>(\n        \".timeline-item-anim\",\n      );\n      // Staggered entrance, replayed from the start whenever the deps change.\n      // `backwards` holds each item hidden through its delay; once done the\n      // effect is dropped and the item rests on its own styles.\n      const animations = Array.from(elements, (el, index) =>\n        el.animate(\n          [\n            { opacity: 0, transform: \"translateY(20px)\" },\n            { opacity: 1, transform: \"translateY(0px)\" },\n          ],\n          {\n            duration: 500,\n            delay: index * 150,\n            easing: EASE_POWER3_OUT,\n            fill: \"backwards\",\n          },\n        ),\n      );\n      return () => animations.forEach((animation) => animation.cancel());\n    }, [animate, items, variant, layout, color]);\n\n    return (\n      // Every breakpoint below is a container query, not a media query. The\n      // timeline is nearly always inside a constrained column, so the viewport\n      // says nothing useful about how much room the rail actually has — a\n      // 672px timeline in a 1400px window would otherwise split into two\n      // 288px columns and shred every card.\n      <div\n        ref={ref}\n        className={cn(\"@container/timeline w-full py-4\", className)}\n        style={style}\n        {...props}\n      >\n        <div\n          ref={containerRef}\n          className=\"relative flex flex-col gap-8 @xl/timeline:gap-12\"\n        >\n          {items.map((item, index) => (\n            <TimelineNode\n              key={item.id}\n              item={item}\n              index={index}\n              isLast={index === items.length - 1}\n              theme={theme}\n              variant={variant}\n              layout={layout}\n            />\n          ))}\n        </div>\n      </div>\n    );\n  },\n);\nTimelineBlock.displayName = \"TimelineBlock\";\n\n// ==========================================\n// NODE COMPONENT\n// ==========================================\nfunction TimelineNode({\n  item,\n  index,\n  isLast,\n  theme,\n  variant,\n  layout,\n}: {\n  item: TimelineItemType;\n  index: number;\n  isLast: boolean;\n  theme: Record<string, string>;\n  variant: TimelineVariant;\n  layout: TimelineLayout;\n}) {\n  const [isExpanded, setIsExpanded] = useState(false);\n  const Icon = item.icon;\n  const hasContent = Boolean(item.content);\n\n  const status = item.status || \"completed\";\n  const isCompleted = status === \"completed\";\n  const isCurrent = status === \"current\";\n  const isUpcoming = status === \"upcoming\";\n\n  // Center layout magic (only applies once the rail itself is wide enough —\n  // see @xl/timeline below; narrower than that it falls back to the left rail)\n  const isEven = index % 2 === 0;\n  const isCenter = layout === \"center\";\n  // Cards whose content hugs the rail from the right: the `right` layout, and\n  // the even (left-hand column) cards of the `center` zig-zag.\n  const railOnRight = layout === \"right\" || (isCenter && isEven);\n\n  const isGlass = variant === \"glass\";\n  const isMinimal = variant === \"minimal\";\n\n  return (\n    <div className=\"timeline-item-anim relative group w-full flex flex-col @xl/timeline:flex-row\">\n      {/* 1. THE VERTICAL LINE (Dynamic positioning based on layout) */}\n      {!isLast && (\n        <div\n          className={cn(\n            \"absolute w-[2px] transition-colors duration-500\",\n            // Narrow rail is always left-aligned\n            \"left-[19px] @xl/timeline:left-auto top-10 bottom-[-32px] @xl/timeline:bottom-[-48px]\",\n            // Wide rail positioning\n            layout === \"left\" && \"@xl/timeline:left-[19px]\",\n            layout === \"right\" && \"@xl/timeline:right-[19px]\",\n            layout === \"center\" &&\n              \"@xl/timeline:left-1/2 @xl/timeline:-translate-x-1/2\",\n            // Colors based on status\n            isGlass ? \"bg-white/10\" : \"bg-muted\",\n            isCompleted && theme.bg, // Fill the line if this node is completed\n          )}\n        />\n      )}\n\n      {/* 2. THE DOT / ICON */}\n      <div\n        className={cn(\n          \"absolute z-10 flex items-center justify-center rounded-full transition-all duration-500\",\n          \"w-10 h-10 left-0 @xl/timeline:left-auto border-2\",\n          // Wide rail positioning\n          layout === \"left\" && \"@xl/timeline:left-0\",\n          layout === \"right\" && \"@xl/timeline:right-0\",\n          layout === \"center\" &&\n            \"@xl/timeline:left-1/2 @xl/timeline:-translate-x-1/2\",\n          // Styling based on status & variant\n          isGlass\n            ? \"bg-black/50 backdrop-blur-md\"\n            : \"bg-background\",\n          isCompleted || isCurrent\n            ? theme.border\n            : isGlass\n              ? \"border-white/20\"\n              : \"border-border\",\n          isCurrent && theme.glow,\n          // Hover effects\n          !isUpcoming && \"group-hover:scale-110\",\n        )}\n      >\n        {Icon ? (\n          <Icon\n            className={cn(\n              \"w-4 h-4 transition-colors\",\n              isCompleted || isCurrent\n                ? theme.text\n                : \"text-muted-foreground\",\n            )}\n          />\n        ) : (\n          <div\n            className={cn(\n              \"w-3 h-3 rounded-full transition-colors\",\n              isCompleted || isCurrent\n                ? theme.bg\n                : \"bg-muted\",\n              isCurrent && \"animate-pulse\",\n            )}\n          />\n        )}\n      </div>\n\n      {/* 3. THE CONTENT CARD */}\n      <div\n        className={cn(\n          \"flex flex-col w-full transition-all duration-300\",\n          // Narrow rail always clears the dot on the left\n          \"pl-16 @xl/timeline:pl-0\",\n          // Wide rail width & positioning\n          layout === \"center\"\n            ? \"@xl/timeline:w-[calc(50%-3rem)]\"\n            : \"@xl/timeline:w-[calc(100%-4rem)]\",\n          layout === \"left\" && \"@xl/timeline:ml-16\",\n          layout === \"right\" && \"@xl/timeline:mr-16 @xl/timeline:text-right\",\n          isCenter &&\n            isEven &&\n            \"@xl/timeline:mr-auto @xl/timeline:pr-0 @xl/timeline:text-right\",\n          isCenter &&\n            !isEven &&\n            \"@xl/timeline:ml-auto @xl/timeline:pl-0 @xl/timeline:text-left\",\n          isUpcoming && \"opacity-60 grayscale hover:grayscale-0\",\n        )}\n      >\n        <div\n          className={cn(\n            \"@container/tlcard flex flex-col gap-3 rounded-2xl transition-all duration-300\",\n            !isMinimal && \"p-5 border shadow-sm\",\n            !isMinimal &&\n              !isGlass &&\n              \"bg-card text-card-foreground border-border\",\n            isGlass &&\n              \"bg-white/5 backdrop-blur-xl border-white/10 hover:bg-white/10\",\n            isMinimal && \"p-1 hover:-translate-y-1\",\n          )}\n        >\n          {/* Header Row (Title, Date, Expand Button) */}\n          <div\n            className={cn(\n              // Keyed to the CARD's width, not the rail's: a center-layout card\n              // is only half the rail, so putting the date beside the title\n              // there leaves the copy ~110px to wrap into. It drops onto its\n              // own line until the card can carry both on one row.\n              \"flex flex-col @lg/tlcard:flex-row justify-between gap-2 @lg/tlcard:gap-4\",\n              railOnRight && \"@lg/tlcard:flex-row-reverse\",\n              hasContent && \"cursor-pointer select-none\",\n            )}\n            onClick={() => hasContent && setIsExpanded(!isExpanded)}\n          >\n            {/* min-w-0 so a long title shrinks the column instead of\n                overflowing it once this is a row. */}\n            <div className=\"flex flex-col gap-1 min-w-0\">\n              <h3\n                className={cn(\n                  \"text-base font-semibold transition-colors\",\n                  isGlass ? \"text-white\" : \"text-foreground\",\n                  \"group-hover:text-[var(--timeline-color)]\",\n                )}\n              >\n                {item.title}\n              </h3>\n              {item.description && (\n                <p\n                  className={cn(\n                    \"text-sm\",\n                    isGlass\n                      ? \"text-zinc-300\"\n                      : \"text-muted-foreground\",\n                  )}\n                >\n                  {item.description}\n                </p>\n              )}\n            </div>\n\n            <div\n              className={cn(\n                \"flex items-center gap-3 shrink-0\",\n                // Stacked, this row is full width, so it needs to be told to\n                // follow the card's text alignment. Once it is a row the div\n                // is content-sized and justify-* is a no-op.\n                railOnRight &&\n                  \"@xl/timeline:justify-end @lg/tlcard:flex-row-reverse\",\n              )}\n            >\n              <span\n                className={cn(\n                  \"text-xs font-semibold px-2.5 py-1 rounded-md whitespace-nowrap\",\n                  isCurrent\n                    ? theme.bg\n                    : isGlass\n                      ? \"bg-white/10 text-zinc-300\"\n                      : \"bg-muted text-muted-foreground\",\n                  isCurrent && theme.on,\n                  isCurrent && \"shadow-sm\",\n                )}\n              >\n                {item.date}\n              </span>\n              {hasContent && (\n                <button\n                  className={cn(\n                    \"p-1.5 rounded-full transition-all\",\n                    isGlass\n                      ? \"hover:bg-white/10 text-zinc-300\"\n                      : \"hover:bg-muted text-muted-foreground\",\n                  )}\n                >\n                  <ChevronDown\n                    className={cn(\n                      \"w-4 h-4 transition-transform duration-300\",\n                      isExpanded && \"rotate-180\",\n                    )}\n                  />\n                </button>\n              )}\n            </div>\n          </div>\n\n          {/* Action Area (e.g. Buttons) */}\n          {item.action && (\n            <div\n              className={cn(\n                \"mt-2\",\n                railOnRight && \"@xl/timeline:flex @xl/timeline:justify-end\",\n              )}\n            >\n              {item.action}\n            </div>\n          )}\n\n          {/* Expandable Content Area (CSS Grid Trick) */}\n          {hasContent && (\n            <div\n              className={cn(\n                \"grid transition-all duration-300 ease-in-out text-left\",\n                isExpanded\n                  ? \"grid-rows-[1fr] opacity-100 mt-2 @lg/tlcard:mt-4\"\n                  : \"grid-rows-[0fr] opacity-0 mt-0\",\n              )}\n            >\n              <div className=\"overflow-hidden\">\n                <div\n                  className={cn(\n                    \"pt-4 border-t\",\n                    isGlass\n                      ? \"border-white/10\"\n                      : \"border-border\",\n                  )}\n                >\n                  {item.content}\n                </div>\n              </div>\n            </div>\n          )}\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/custom/blocks/TimelineBlock.tsx"
    },
    {
      "path": "src/components/custom/blocks/timeline-theme.ts",
      "content": "\"use client\";\n\nimport React from \"react\";\n\nconst colorThemes: Record<string, Record<string, string>> = {\n  primary: {\n    bg: \"bg-primary\",\n    on: \"text-primary-foreground\",\n    text: \"text-primary\",\n    border: \"border-primary/30\",\n    glow: \"shadow-[0_0_15px_color-mix(in_oklab,var(--primary)_50%,transparent)]\",\n  },\n  indigo: {\n    bg: \"bg-indigo-600\",\n    on: \"text-white\",\n    text: \"text-indigo-600 dark:text-indigo-400\",\n    border: \"border-indigo-500\",\n    glow: \"shadow-[0_0_15px_rgba(99,102,241,0.5)]\",\n  },\n  rose: {\n    bg: \"bg-rose-600\",\n    on: \"text-white\",\n    text: \"text-rose-600 dark:text-rose-400\",\n    border: \"border-rose-500\",\n    glow: \"shadow-[0_0_15px_rgba(225,29,72,0.5)]\",\n  },\n  emerald: {\n    bg: \"bg-emerald-600\",\n    on: \"text-white\",\n    text: \"text-emerald-600 dark:text-emerald-400\",\n    border: \"border-emerald-500\",\n    glow: \"shadow-[0_0_15px_rgba(16,185,129,0.5)]\",\n  },\n  blue: {\n    bg: \"bg-blue-600\",\n    on: \"text-white\",\n    text: \"text-blue-600 dark:text-blue-400\",\n    border: \"border-blue-500\",\n    glow: \"shadow-[0_0_15px_rgba(59,130,246,0.5)]\",\n  },\n  violet: {\n    bg: \"bg-violet-600\",\n    on: \"text-white\",\n    text: \"text-violet-600 dark:text-violet-400\",\n    border: \"border-violet-500\",\n    glow: \"shadow-[0_0_15px_rgba(139,92,246,0.5)]\",\n  },\n  zinc: {\n    bg: \"bg-zinc-900 dark:bg-zinc-100\",\n    on: \"text-white dark:text-zinc-900\",\n    text: \"text-zinc-900 dark:text-zinc-100\",\n    border: \"border-zinc-900 dark:border-zinc-100\",\n    glow: \"shadow-[0_0_15px_rgba(255,255,255,0.3)] dark:shadow-[0_0_15px_rgba(255,255,255,0.4)]\",\n  },\n};\n\nconst hexToRgb = (hex: string) => {\n  let cleanHex = hex.replace(/^#/, \"\");\n  if (cleanHex.length === 3)\n    cleanHex = cleanHex\n      .split(\"\")\n      .map((x) => x + x)\n      .join(\"\");\n  const result = /^([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(cleanHex);\n  return result\n    ? `${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)}`\n    : \"99, 102, 241\";\n};\n\nconst relLuminance = (rgb: string) => {\n  const [r, g, b] = rgb.split(\",\").map((n) => {\n    const v = Number(n.trim()) / 255;\n    return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);\n  });\n  return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nexport const getThemeStyles = (color: string) => {\n  if (color && color.startsWith(\"#\")) {\n    const rgb = hexToRgb(color);\n    return {\n      theme: {\n        bg: \"bg-[var(--timeline-color)]\",\n        on: \"text-[var(--timeline-on-color)]\",\n        text: \"text-[var(--timeline-color)]\",\n        border: \"border-[var(--timeline-color)]\",\n        glow: \"shadow-[0_0_15px_var(--timeline-glow)]\",\n      },\n      style: {\n        \"--timeline-color\": color,\n        \"--timeline-on-color\":\n          relLuminance(rgb) > 0.45 ? \"#09090b\" : \"#ffffff\",\n        \"--timeline-glow\": `rgba(${rgb}, 0.5)`,\n      } as React.CSSProperties,\n    };\n  }\n  return { theme: colorThemes[color] || colorThemes.primary, style: {} };\n};\n",
      "type": "registry:component",
      "target": "components/custom/blocks/timeline-theme.ts"
    }
  ],
  "docs": "Named exports: TimelineBlock, getThemeStyles (from timeline-theme.ts, which installs alongside). Items take { id, title, date, description?, icon?, status } where status is completed | current | upcoming and drives the colour. `layout` places entries left | center | right. For entrance animation variety without status semantics, use `animated-timeline`.",
  "categories": [
    "data-display"
  ],
  "type": "registry:component"
}
