{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "category-row",
  "type": "registry:ui",
  "title": "Category Row",
  "description": "A reusable category row: pictogram, label, optional NEW badge, gradient underline and horizontal scrolling with arrows on small screens.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge",
    "lucide-react"
  ],
  "registryDependencies": [
    "https://prequeluianimate.terravidhal.me/r/react/categories/category-core.json"
  ],
  "meta": {
    "style": "category",
    "display": 40,
    "itemHeight": 62,
    "underline": "24 x 2",
    "hover": "100 ms ease-out"
  },
  "files": [
    {
      "path": "components/prequelui/categories/category-row.tsx",
      "target": "components/prequelui/categories/category-row.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport {\n  CategoryPictogram,\n  type CategoryPictogramDefinition,\n} from \"./category-core\";\n\nexport type CategoryRowItem = {\n  definition: CategoryPictogramDefinition;\n  label?: string;\n  href?: string;\n  badge?: string;\n  active?: boolean;\n};\n\nexport type CategoryRowProps = {\n  items: CategoryRowItem[];\n  size?: number;\n  className?: string;\n  ariaLabel?: string;\n  onSelect?: (item: CategoryRowItem) => void;\n};\n\nfunction gradientOf(definition: CategoryPictogramDefinition) {\n  const { light, dark } = definition.palette;\n  return `linear-gradient(45deg, light-dark(${light[0]}, ${dark[0]}), light-dark(${light[1]}, ${dark[1]}))`;\n}\n\nexport function CategoryRow({\n  items,\n  size = 40,\n  className,\n  ariaLabel = \"Categories\",\n  onSelect,\n}: CategoryRowProps) {\n  const scroller = React.useRef<HTMLDivElement>(null);\n  const [hovered, setHovered] = React.useState<string | null>(null);\n  const [state, setState] = React.useState({\n    left: false,\n    right: false,\n    overflow: false,\n  });\n\n  const measure = React.useCallback(() => {\n    const node = scroller.current;\n    if (!node) return;\n    const max = node.scrollWidth - node.clientWidth;\n    setState({\n      left: node.scrollLeft > 1,\n      right: max - node.scrollLeft > 1,\n      overflow: max > 1,\n    });\n  }, []);\n\n  React.useEffect(() => {\n    const node = scroller.current;\n    if (!node) return;\n    measure();\n    node.addEventListener(\"scroll\", measure, { passive: true });\n    const observer = new ResizeObserver(measure);\n    observer.observe(node);\n    return () => {\n      node.removeEventListener(\"scroll\", measure);\n      observer.disconnect();\n    };\n  }, [measure]);\n\n  const scrollBy = (direction: -1 | 1) => {\n    const node = scroller.current;\n    if (!node) return;\n    const amount = Math.max(240, Math.round(node.clientWidth * 0.7));\n    node.scrollBy({\n      left: direction * amount,\n      behavior: window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n        ? \"auto\"\n        : \"smooth\",\n    });\n  };\n\n  return (\n    <nav\n      aria-label={ariaLabel}\n      className={cn(\"relative w-full\", className)}\n      data-category-row=\"\"\n    >\n      <div\n        ref={scroller}\n        className=\"overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n      >\n        <ul className=\"mx-auto flex w-max min-w-full items-stretch justify-center px-3 py-4\">\n          {items.map((item, index) => {\n            const { definition } = item;\n            const label = item.label ?? definition.name;\n            const iconActive =\n              hovered === definition.slug && !item.active ? true : undefined;\n            const content = (\n              <>\n                <CategoryPictogram\n                  definition={definition}\n                  size={size}\n                  active={item.active ? true : iconActive}\n                  className=\"text-foreground\"\n                />\n                <span\n                  data-category-label=\"\"\n                  className={cn(\n                    \"w-full text-center text-[15px] leading-[19px] text-foreground\",\n                    item.active && \"font-medium\",\n                  )}\n                >\n                  {label}\n                </span>\n                <span\n                  aria-hidden=\"true\"\n                  className={cn(\n                    \"pointer-events-none absolute -bottom-[5px] left-1/2 h-0.5 w-6 -translate-x-1/2 origin-center rounded-full bg-background transition-transform duration-100 ease-out\",\n                    \"scale-x-0 group-hover/cat:scale-x-100 group-focus-visible/cat:scale-x-100\",\n                    item.active && \"scale-x-100\",\n                    \"motion-reduce:transition-none\",\n                  )}\n                  style={{ backgroundImage: gradientOf(definition) }}\n                />\n                {item.badge ? (\n                  <span\n                    className=\"absolute -left-1 -top-2 rounded-full px-1.5 py-0.5 text-[13px] font-semibold uppercase leading-none\"\n                    style={{\n                      backgroundImage: gradientOf(definition),\n                      color: \"light-dark(#ffffff, #171717)\",\n                    }}\n                  >\n                    {item.badge}\n                  </span>\n                ) : null}\n              </>\n            );\n\n            const shared = cn(\n              \"group/cat relative flex min-w-14 select-none flex-col items-center gap-1 rounded-md py-3 outline-none\",\n              \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background\",\n              \"max-md:py-2.5\",\n            );\n\n            return (\n              <li\n                key={definition.slug}\n                className=\"shrink-0 snap-start px-2.5\"\n                onPointerEnter={() => setHovered(definition.slug)}\n                onPointerLeave={() =>\n                  setHovered((value) =>\n                    value === definition.slug ? null : value,\n                  )\n                }\n              >\n                {item.href ? (\n                  <a\n                    href={item.href}\n                    aria-current={item.active ? \"page\" : undefined}\n                    className={shared}\n                    onFocus={() => setHovered(definition.slug)}\n                    onBlur={() => setHovered(null)}\n                  >\n                    {content}\n                  </a>\n                ) : (\n                  <button\n                    type=\"button\"\n                    aria-current={item.active ? \"page\" : undefined}\n                    onClick={() => onSelect?.(item)}\n                    className={shared}\n                    onFocus={() => setHovered(definition.slug)}\n                    onBlur={() => setHovered(null)}\n                  >\n                    {content}\n                  </button>\n                )}\n              </li>\n            );\n          })}\n        </ul>\n      </div>\n\n      {state.overflow ? (\n        <>\n          <button\n            type=\"button\"\n            aria-label=\"Scroll categories left\"\n            tabIndex={state.left ? 0 : -1}\n            onClick={() => scrollBy(-1)}\n            className={cn(\n              \"absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center bg-background text-muted-foreground transition-[opacity,transform] duration-100 ease-in-out hover:text-foreground\",\n              state.left\n                ? \"translate-x-0 opacity-100\"\n                : \"-translate-x-2 opacity-0 pointer-events-none\",\n            )}\n          >\n            <ChevronLeft className=\"size-4\" />\n          </button>\n          <button\n            type=\"button\"\n            aria-label=\"Scroll categories right\"\n            tabIndex={state.right ? 0 : -1}\n            onClick={() => scrollBy(1)}\n            className={cn(\n              \"absolute inset-y-0 right-0 z-10 flex w-8 items-center justify-center bg-background text-muted-foreground transition-[opacity,transform] duration-100 ease-in-out hover:text-foreground\",\n              state.right\n                ? \"translate-x-0 opacity-100\"\n                : \"translate-x-2 opacity-0 pointer-events-none\",\n            )}\n          >\n            <ChevronRight className=\"size-4\" />\n          </button>\n        </>\n      ) : null}\n    </nav>\n  );\n}\n"
    }
  ]
}
