{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"dot-grid-background","type":"registry:block","title":"Dot grid background","description":"A dotted section background whose dots brighten around the pointer and breathe slowly, with children rendered on top and a calm static grid for reduced motion.","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/dot-grid-background/dot-grid-background.tsx","type":"registry:component","content":"\"use client\";\n\nimport {\n  useEffect,\n  useRef,\n  useState,\n  type CSSProperties,\n  type PointerEvent as ReactPointerEvent,\n  type ReactNode,\n} from \"react\";\nimport { useReducedMotion } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\n/* The dots breathe on a long, slow cycle so the background never sits\n   completely still. Reduced motion gets the same grid, frozen. */\nconst DOTS_CSS = `\n@keyframes prequel-dots-breathe {\n  0%, 100% { opacity: 0.16; }\n  50% { opacity: 0.3; }\n}\n.prequel-dots-breathe {\n  animation: prequel-dots-breathe 7s ease-in-out infinite;\n}\n.prequel-dots-static {\n  opacity: 0.22;\n}\n@media (prefers-reduced-motion: reduce) {\n  .prequel-dots-breathe {\n    animation: none;\n    opacity: 0.22;\n  }\n}\n`;\n\nconst DOT_IMAGE =\n  \"radial-gradient(circle at 1px 1px, var(--muted-foreground) 1px, transparent 0)\";\nconst LIT_DOT_IMAGE =\n  \"radial-gradient(circle at 1px 1px, var(--foreground) 1px, transparent 0)\";\n\n/* ------------------------------------------------------------------ */\n/* types                                                               */\n/* ------------------------------------------------------------------ */\n\nexport type DotGridBackgroundProps = {\n  className?: string;\n  children?: ReactNode;\n  /** Gap between dots, in pixels. Defaults to 22. */\n  spacing?: number;\n  /** Radius of the pointer highlight, in pixels. Defaults to 220. */\n  radius?: number;\n};\n\n/* ------------------------------------------------------------------ */\n/* block                                                               */\n/* ------------------------------------------------------------------ */\n\nexport function DotGridBackground({\n  className,\n  children,\n  spacing = 22,\n  radius = 220,\n}: DotGridBackgroundProps) {\n  const reduce = Boolean(useReducedMotion());\n  const ref = useRef<HTMLDivElement | null>(null);\n  const frame = useRef<number | null>(null);\n  const pending = useRef({ x: 0, y: 0 });\n  const [spot, setSpot] = useState({ x: 0, y: 0 });\n  const [active, setActive] = useState(false);\n\n  useEffect(() => {\n    return () => {\n      if (frame.current !== null) window.cancelAnimationFrame(frame.current);\n    };\n  }, []);\n\n  /* Coalesce pointer moves into one update per frame. */\n  const follow = (event: ReactPointerEvent<HTMLDivElement>) => {\n    if (reduce) return;\n    const rect = ref.current?.getBoundingClientRect();\n    if (!rect) return;\n\n    pending.current = {\n      x: event.clientX - rect.left,\n      y: event.clientY - rect.top,\n    };\n\n    if (frame.current !== null) return;\n    frame.current = window.requestAnimationFrame(() => {\n      frame.current = null;\n      setSpot(pending.current);\n    });\n  };\n\n  const gap = Math.max(10, spacing);\n  const glow = Math.max(80, radius);\n\n  const dots: CSSProperties = {\n    backgroundImage: DOT_IMAGE,\n    backgroundSize: `${gap}px ${gap}px`,\n  };\n\n  const lit: CSSProperties = {\n    backgroundImage: LIT_DOT_IMAGE,\n    backgroundSize: `${gap}px ${gap}px`,\n    maskImage: `radial-gradient(circle ${glow}px at ${spot.x}px ${spot.y}px, #000 0%, transparent 100%)`,\n    WebkitMaskImage: `radial-gradient(circle ${glow}px at ${spot.x}px ${spot.y}px, #000 0%, transparent 100%)`,\n    opacity: active && !reduce ? 0.45 : 0,\n  };\n\n  return (\n    <div\n      ref={ref}\n      onPointerMove={follow}\n      onPointerEnter={(event) => {\n        setActive(true);\n        follow(event);\n      }}\n      onPointerLeave={() => setActive(false)}\n      className={cn(\n        \"relative isolate min-h-[300px] overflow-hidden rounded-xl border border-border bg-card text-card-foreground\",\n        className\n      )}\n    >\n      <style>{DOTS_CSS}</style>\n\n      <div\n        aria-hidden=\"true\"\n        className={cn(\n          \"pointer-events-none absolute inset-0\",\n          reduce ? \"prequel-dots-static\" : \"prequel-dots-breathe\"\n        )}\n        style={dots}\n      />\n      <div\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-0 transition-opacity duration-300 ease-out\"\n        style={lit}\n      />\n\n      <div className=\"relative\">\n        {children ?? (\n          <div className=\"mx-auto flex max-w-2xl flex-col gap-3 px-6 py-16 sm:px-10\">\n            <span className=\"text-[12.5px] font-medium text-muted-foreground\">\n              Release 2.4.0\n            </span>\n            <h2 className=\"text-balance text-2xl font-semibold tracking-tight sm:text-3xl\">\n              Search is 3.2× faster, and webhooks now retry for 24 hours.\n            </h2>\n            <p className=\"max-w-md text-[14px] leading-relaxed text-muted-foreground\">\n              Audit logs keep 18 months of history, and the new export job runs\n              every night at 02:00 UTC.\n            </p>\n          </div>\n        )}\n      </div>\n    </div>\n  );\n}\n\n/* The default section on its own, handy for previews. */\nexport function DotGridBackgroundDemo() {\n  return <DotGridBackground />;\n}\n\nexport default DotGridBackground;\n"}]}