{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"row-slide","type":"registry:ui","title":"Row Slide","description":"Tilted rows of tiles that slide in alternating directions as the cursor moves across.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/row-slide.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef } from \"react\";\n\nexport interface RowSlideProps {\n  /** Tile contents: image URLs or short labels. Repeats to fill the grid. */\n  items?: string[];\n  rows?: number;\n  columns?: number;\n  /** Grid rotation in degrees. */\n  tilt?: number;\n  /** Max horizontal slide in px when the cursor is at an edge. */\n  strength?: number;\n  /** Gap between tiles in px. */\n  gap?: number;\n  className?: string;\n}\n\nconst isImage = (s: string) => /^(https?:|\\/|\\.|data:image|blob:)/.test(s);\n\nexport function RowSlide({\n  items = [],\n  rows = 4,\n  columns = 7,\n  tilt = -12,\n  strength = 260,\n  gap = 16,\n  className,\n}: RowSlideProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  const rowRefs = useRef<(HTMLDivElement | null)[]>([]);\n\n  useEffect(() => {\n    const host = ref.current!;\n    const zone = host.parentElement ?? host;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let target = 0; // -0.5..0.5, cursor x relative to center\n    const pos = rowRefs.current.map(() => 0);\n    let raf = 0;\n\n    const tick = () => {\n      let moving = false;\n      rowRefs.current.forEach((row, i) => {\n        if (!row) return;\n        const goal = target * strength * (i % 2 ? -1 : 1);\n        // each row trails at its own pace for a layered feel\n        pos[i] += (goal - pos[i]) * (0.05 + 0.025 * (i % 3));\n        if (Math.abs(goal - pos[i]) > 0.1) moving = true;\n        row.style.transform = `translate3d(${pos[i].toFixed(2)}px,0,0)`;\n      });\n      raf = moving ? requestAnimationFrame(tick) : 0;\n    };\n    const kick = () => {\n      if (!raf) raf = requestAnimationFrame(tick);\n    };\n    const move = (e: PointerEvent) => {\n      const r = host.getBoundingClientRect();\n      target = (e.clientX - r.left) / r.width - 0.5;\n      kick();\n    };\n    const leave = () => {\n      target = 0;\n      kick();\n    };\n    zone.addEventListener(\"pointermove\", move);\n    zone.addEventListener(\"pointerleave\", leave);\n    return () => {\n      cancelAnimationFrame(raf);\n      zone.removeEventListener(\"pointermove\", move);\n      zone.removeEventListener(\"pointerleave\", leave);\n    };\n  }, [strength, rows]);\n\n  return (\n    <div\n      ref={ref}\n      aria-hidden\n      className={className}\n      style={{ position: \"absolute\", inset: 0, overflow: \"hidden\", pointerEvents: \"none\" }}\n    >\n      <div\n        style={{\n          position: \"absolute\",\n          left: \"50%\",\n          top: \"50%\",\n          width: \"150%\",\n          height: \"150%\",\n          display: \"flex\",\n          flexDirection: \"column\",\n          justifyContent: \"center\",\n          gap,\n          transform: `translate(-50%, -50%) rotate(${tilt}deg)`,\n        }}\n      >\n        {Array.from({ length: rows }, (_, r) => (\n          <div\n            key={r}\n            ref={(el) => {\n              rowRefs.current[r] = el;\n            }}\n            style={{ display: \"flex\", gap, flex: 1, minHeight: 0, willChange: \"transform\" }}\n          >\n            {Array.from({ length: columns }, (_, c) => {\n              const n = r * columns + c;\n              const item = items.length ? items[n % items.length] : String(n + 1).padStart(2, \"0\");\n              return (\n                <div\n                  key={c}\n                  className=\"relative flex-1 overflow-hidden rounded-2xl border border-border bg-muted\"\n                  style={\n                    isImage(item)\n                      ? { backgroundImage: `url(\"${item}\")`, backgroundSize: \"cover\", backgroundPosition: \"center\" }\n                      : undefined\n                  }\n                >\n                  {!isImage(item) && (\n                    <span className=\"absolute inset-0 grid place-items-center text-2xl font-semibold text-muted-foreground\">\n                      {item}\n                    </span>\n                  )}\n                </div>\n              );\n            })}\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n"}]}