{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"marquee","type":"registry:block","title":"Marquee","description":"An infinite two-row logo band drifting in opposite directions, with soft edge fades and pause on hover or focus.","dependencies":["motion","lucide-react"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/marquee/marquee.tsx","type":"registry:component","content":"\"use client\";\n\nimport { useId, useRef, useState } from \"react\";\nimport {\n  MotionConfig,\n  motion,\n  useInView,\n  useReducedMotion,\n} from \"motion/react\";\nimport { Pause, Play } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\nconst LOGOS_PER_ROW = 8;\n\n/* two identical copies of a row make the loop seamless */\nconst KEYFRAMES = `\n@keyframes prequel-marquee-scroll {\n  from { transform: translateX(0); }\n  to { transform: translateX(-50%); }\n}\n`;\n\n/* ------------------------------------------------------------------ */\n/* types                                                               */\n/* ------------------------------------------------------------------ */\n\nexport type MarqueeMark =\n  | \"orbit\"\n  | \"arc\"\n  | \"wave\"\n  | \"grid\"\n  | \"prism\"\n  | \"diamond\"\n  | \"stack\"\n  | \"split\";\n\nexport type MarqueeLogo = {\n  id: string;\n  name: string;\n  /** A small geometric mark drawn beside the wordmark. */\n  mark?: MarqueeMark;\n};\n\nexport type MarqueeProps = {\n  className?: string;\n  heading?: string;\n  /** A short line of context under the heading. */\n  note?: string;\n  logos?: MarqueeLogo[];\n  /** Seconds for one full loop of a row. Defaults to 36. */\n  duration?: number;\n};\n\n/* ------------------------------------------------------------------ */\n/* deterministic demo data                                             */\n/* ------------------------------------------------------------------ */\n\nconst DEFAULT_LOGOS: MarqueeLogo[] = [\n  { id: \"northwind\", name: \"Northwind Labs\", mark: \"orbit\" },\n  { id: \"halo\", name: \"Halo Cloud\", mark: \"arc\" },\n  { id: \"bluebird\", name: \"Bluebird Studio\", mark: \"wave\" },\n  { id: \"sable\", name: \"Sable Systems\", mark: \"grid\" },\n  { id: \"kite\", name: \"Kite & Co\", mark: \"prism\" },\n  { id: \"meridian\", name: \"Meridian Works\", mark: \"diamond\" },\n  { id: \"calder\", name: \"Calder & Finch\", mark: \"stack\" },\n  { id: \"lumen\", name: \"Lumen Field\", mark: \"split\" },\n  { id: \"harborline\", name: \"Harborline\", mark: \"orbit\" },\n  { id: \"fathom\", name: \"Fathom\", mark: \"arc\" },\n  { id: \"copperline\", name: \"Copperline\", mark: \"wave\" },\n  { id: \"tessellate\", name: \"Tessellate\", mark: \"grid\" },\n];\n\n/* ------------------------------------------------------------------ */\n/* marks                                                               */\n/* ------------------------------------------------------------------ */\n\nfunction LogoMark({ shape }: { shape: MarqueeMark }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth={1.5}\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      className=\"h-[18px] w-[18px] shrink-0\"\n    >\n      {shape === \"orbit\" ? (\n        <>\n          <circle cx=\"12\" cy=\"12\" r=\"4.5\" />\n          <ellipse\n            cx=\"12\"\n            cy=\"12\"\n            rx=\"9.5\"\n            ry=\"3.5\"\n            transform=\"rotate(-25 12 12)\"\n          />\n        </>\n      ) : null}\n\n      {shape === \"arc\" ? (\n        <>\n          <path d=\"M4 17a8 8 0 0 1 16 0\" />\n          <circle cx=\"4\" cy=\"17\" r=\"1\" fill=\"currentColor\" stroke=\"none\" />\n          <circle cx=\"20\" cy=\"17\" r=\"1\" fill=\"currentColor\" stroke=\"none\" />\n        </>\n      ) : null}\n\n      {shape === \"wave\" ? (\n        <path d=\"M3 14c3-7 6-7 9 0s6 7 9 0\" />\n      ) : null}\n\n      {shape === \"grid\" ? (\n        <>\n          <rect x=\"4.5\" y=\"4.5\" width=\"6\" height=\"6\" rx=\"1.2\" />\n          <rect x=\"13.5\" y=\"4.5\" width=\"6\" height=\"6\" rx=\"1.2\" />\n          <rect x=\"4.5\" y=\"13.5\" width=\"6\" height=\"6\" rx=\"1.2\" />\n          <rect x=\"13.5\" y=\"13.5\" width=\"6\" height=\"6\" rx=\"1.2\" />\n        </>\n      ) : null}\n\n      {shape === \"prism\" ? (\n        <>\n          <path d=\"M12 4 20 19H4L12 4Z\" />\n          <path d=\"M12 9v5\" />\n        </>\n      ) : null}\n\n      {shape === \"diamond\" ? (\n        <>\n          <path d=\"M12 3.5 20.5 12 12 20.5 3.5 12 12 3.5Z\" />\n          <circle cx=\"12\" cy=\"12\" r=\"1.4\" fill=\"currentColor\" stroke=\"none\" />\n        </>\n      ) : null}\n\n      {shape === \"stack\" ? (\n        <path d=\"M4.5 7.5h15M7.5 12h9M4.5 16.5h15\" />\n      ) : null}\n\n      {shape === \"split\" ? (\n        <>\n          <circle cx=\"7\" cy=\"7\" r=\"2.8\" />\n          <circle cx=\"17\" cy=\"17\" r=\"2.8\" />\n          <path d=\"m9 9 6 6\" />\n        </>\n      ) : null}\n    </svg>\n  );\n}\n\n/* ------------------------------------------------------------------ */\n/* one wordmark                                                        */\n/* ------------------------------------------------------------------ */\n\nfunction LogoItem({\n  logo,\n  still = false,\n}: {\n  logo: MarqueeLogo;\n  still?: boolean;\n}) {\n  return (\n    <span\n      className={cn(\n        \"flex shrink-0 items-center gap-2.5 text-muted-foreground transition-colors duration-200 hover:text-foreground\",\n        still\n          ? \"\"\n          : \"min-w-[168px] justify-center px-4 sm:min-w-[184px]\"\n      )}\n    >\n      <LogoMark shape={logo.mark ?? \"orbit\"} />\n      <span className=\"whitespace-nowrap text-[13px] font-medium tracking-[-0.01em]\">\n        {logo.name}\n      </span>\n    </span>\n  );\n}\n\n/* ------------------------------------------------------------------ */\n/* a row                                                               */\n/* ------------------------------------------------------------------ */\n\nfunction MarqueeRow({\n  items,\n  direction,\n  duration,\n  paused,\n}: {\n  items: MarqueeLogo[];\n  direction: \"left\" | \"right\";\n  duration: number;\n  paused: boolean;\n}) {\n  if (items.length === 0) return null;\n\n  return (\n    <div className=\"relative overflow-hidden\">\n      <div\n        className=\"marquee-track flex w-max\"\n        style={{\n          animation: `prequel-marquee-scroll ${duration}s linear infinite`,\n          animationDirection: direction === \"right\" ? \"reverse\" : \"normal\",\n          animationPlayState: paused ? \"paused\" : \"running\",\n        }}\n      >\n        {[0, 1].map((copy) => (\n          <div\n            key={copy}\n            aria-hidden={copy === 1 ? true : undefined}\n            className=\"flex shrink-0 items-center\"\n          >\n            {items.map((logo, index) => (\n              <LogoItem key={`${copy}-${logo.id}-${index}`} logo={logo} />\n            ))}\n          </div>\n        ))}\n      </div>\n\n      <div\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-y-0 left-0 w-12 bg-gradient-to-r from-card to-transparent\"\n      />\n      <div\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-y-0 right-0 w-12 bg-gradient-to-l from-card to-transparent\"\n      />\n    </div>\n  );\n}\n\n/* ------------------------------------------------------------------ */\n/* the block                                                           */\n/* ------------------------------------------------------------------ */\n\nexport function Marquee({\n  className,\n  heading = \"Teams shipping with PrequelUI\",\n  note = \"2,418 teams, from seed stage to public.\",\n  logos = DEFAULT_LOGOS,\n  duration = 36,\n}: MarqueeProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  const inView = useInView(ref, { once: true, margin: \"-10% 0px\" });\n  const reduce = Boolean(useReducedMotion());\n  const headingId = useId();\n\n  const [hovering, setHovering] = useState(false);\n  const [focusWithin, setFocusWithin] = useState(false);\n  const [manualPaused, setManualPaused] = useState(false);\n\n  const base = logos.length > 0 ? logos : DEFAULT_LOGOS;\n  const repeat = Math.max(1, Math.ceil((LOGOS_PER_ROW * 2) / base.length));\n  const expanded = Array.from({ length: repeat }, () => base).flat();\n  const split = Math.ceil(expanded.length / 2);\n  const rowOne = expanded.slice(0, split);\n  const rowTwo = expanded.slice(split);\n\n  const paused = hovering || focusWithin || manualPaused;\n  const safeDuration = Math.max(8, duration);\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <style>{KEYFRAMES}</style>\n      <motion.div\n        ref={ref}\n        initial={reduce ? false : { opacity: 0, y: 14 }}\n        animate={\n          reduce || inView ? { opacity: 1, y: 0 } : { opacity: 0, y: 14 }\n        }\n        transition={{ duration: reduce ? 0 : 0.6, ease: EASE }}\n        onPointerEnter={() => setHovering(true)}\n        onPointerLeave={() => setHovering(false)}\n        onFocusCapture={() => setFocusWithin(true)}\n        onBlurCapture={(event) => {\n          const next = event.relatedTarget as Node | null;\n          if (!next || !event.currentTarget.contains(next)) {\n            setFocusWithin(false);\n          }\n        }}\n        className={cn(\"w-full text-foreground\", className)}\n      >\n        <section\n          aria-labelledby={headingId}\n          className=\"overflow-hidden rounded-xl border border-border bg-card text-card-foreground\"\n        >\n          <header className=\"flex items-start justify-between gap-4 px-4 pb-4 pt-4 sm:px-5 sm:pb-5 sm:pt-5\">\n            <div className=\"min-w-0\">\n              <h2\n                id={headingId}\n                className=\"text-[15px] font-medium tracking-[-0.01em] text-foreground\"\n              >\n                {heading}\n              </h2>\n              {note ? (\n                <p className=\"mt-0.5 text-[12px] leading-relaxed text-muted-foreground\">\n                  {note}\n                </p>\n              ) : null}\n            </div>\n\n            {reduce ? null : (\n              <button\n                type=\"button\"\n                onClick={() => setManualPaused((value) => !value)}\n                aria-pressed={manualPaused}\n                aria-label={\n                  manualPaused ? \"Resume the logo band\" : \"Pause the logo band\"\n                }\n                className=\"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border bg-card text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n              >\n                {manualPaused ? (\n                  <Play className=\"h-3 w-3\" aria-hidden=\"true\" />\n                ) : (\n                  <Pause className=\"h-3 w-3\" aria-hidden=\"true\" />\n                )}\n              </button>\n            )}\n          </header>\n\n          <div className=\"border-t border-border\">\n            {reduce ? (\n              <div className=\"flex flex-wrap items-center gap-x-8 gap-y-5 px-4 py-5 sm:px-5\">\n                {base.map((logo) => (\n                  <LogoItem key={logo.id} logo={logo} still />\n                ))}\n              </div>\n            ) : (\n              <div className=\"flex flex-col gap-2 py-4 sm:gap-3 sm:py-5\">\n                <MarqueeRow\n                  items={rowOne}\n                  direction=\"left\"\n                  duration={safeDuration}\n                  paused={paused}\n                />\n                {rowTwo.length > 0 ? (\n                  <MarqueeRow\n                    items={rowTwo}\n                    direction=\"right\"\n                    duration={safeDuration}\n                    paused={paused}\n                  />\n                ) : null}\n              </div>\n            )}\n          </div>\n        </section>\n      </motion.div>\n    </MotionConfig>\n  );\n}\n\nexport default Marquee;\n"}]}