{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-gallery-grid",
  "title": "Motion Gallery Grid",
  "description": "A perfectly aligned image grid with a centered glassmorphism overlay card, heading, subtitle and CTA button, with a staggered blur/slide/fade/scale entrance triggered on scroll into view.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/motion-gallery-grid/motion-gallery-grid.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, type Variants } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type MotionGalleryAnimation = \"blur\" | \"slide\" | \"fade\" | \"scale\";\n\nexport interface MotionGalleryItem {\n  image: string;\n  caption?: string;\n}\n\nexport interface MotionGalleryGridProps extends Omit<React.ComponentPropsWithoutRef<\"section\">, \"children\"> {\n  items?: MotionGalleryItem[];\n  title?: string;\n  subtitle?: string;\n  buttonText?: string;\n  buttonLink?: string;\n  theme?: \"dark\" | \"light\";\n  animationType?: MotionGalleryAnimation;\n  columns?: number;\n  showOverlay?: boolean;\n}\n\nconst THEMES = {\n  dark: { overlayBg: \"rgba(12,12,12,0.78)\", overlayBorder: \"rgba(255,255,255,0.1)\", title: \"#ffffff\", subtitle: \"rgba(255,255,255,0.6)\", buttonBg: \"#ffffff\", buttonText: \"#121212\", imageBg: \"rgba(30,30,30,0.6)\" },\n  light: { overlayBg: \"rgba(255,255,255,0.88)\", overlayBorder: \"rgba(18,18,18,0.08)\", title: \"#121212\", subtitle: \"rgba(18,18,18,0.55)\", buttonBg: \"#121212\", buttonText: \"#ffffff\", imageBg: \"rgba(240,240,240,0.8)\" },\n};\n\nconst VARIANTS: Record<MotionGalleryAnimation, Variants> = {\n  blur: { hidden: { opacity: 0, y: 20, filter: \"blur(10px)\" }, show: { opacity: 1, y: 0, filter: \"blur(0px)\" } },\n  slide: { hidden: { opacity: 0, y: 28 }, show: { opacity: 1, y: 0 } },\n  fade: { hidden: { opacity: 0 }, show: { opacity: 1 } },\n  scale: { hidden: { opacity: 0, scale: 0.94 }, show: { opacity: 1, scale: 1 } },\n};\n\nconst DEFAULT_ITEMS: MotionGalleryItem[] = [\n  \"101\", \"102\", \"104\", \"105\", \"108\", \"109\", \"110\", \"111\", \"11\", \"12\", \"23\", \"103\",\n].map((n) => ({ image: `/demo/${n}.webp` }));\n\nconst NOISE_BG = `url(\"data:image/svg+xml,${encodeURIComponent(\n  `<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(#n)'/></svg>`,\n)}\")`;\n\nfunction useContainerWidth(ref: React.RefObject<HTMLElement | null>) {\n  const [width, setWidth] = React.useState(1100);\n  React.useEffect(() => {\n    if (!ref.current) return;\n    const ro = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));\n    ro.observe(ref.current);\n    return () => ro.disconnect();\n  }, [ref]);\n  return width;\n}\n\nexport function MotionGalleryGrid({\n  items = DEFAULT_ITEMS,\n  title = \"Motion,\\nCaptured in Stillness\",\n  subtitle = \"A visual study of speed, discipline, and the athletes who chase both.\",\n  buttonText = \"Explore the Series\",\n  buttonLink = \"#\",\n  theme = \"dark\",\n  animationType = \"fade\",\n  columns = 4,\n  showOverlay = true,\n  className,\n  style,\n  ...props\n}: MotionGalleryGridProps) {\n  const t = THEMES[theme];\n  const variant = VARIANTS[animationType];\n  const titleId = React.useId();\n  const rootRef = React.useRef<HTMLElement>(null);\n  const containerWidth = useContainerWidth(rootRef);\n  const isMobile = containerWidth < 640;\n  const isTablet = containerWidth < 900;\n  const effectiveColumns = isMobile ? 2 : isTablet ? 3 : columns;\n  const titleText = title.replace(/\\n/g, \" \");\n\n  return (\n    <section\n      ref={rootRef}\n      aria-labelledby={showOverlay ? titleId : undefined}\n      aria-label={showOverlay ? undefined : titleText}\n      className={cn(\"relative w-full overflow-hidden\", className)}\n      style={style}\n      {...props}\n    >\n      <motion.div\n        className=\"grid w-full gap-3 p-3\"\n        style={{ gridTemplateColumns: `repeat(${effectiveColumns}, 1fr)` }}\n        initial=\"hidden\"\n        whileInView=\"show\"\n        viewport={{ once: true, amount: 0.1 }}\n        transition={{ staggerChildren: 0.06 }}\n      >\n        {items.map((item, i) => (\n          <motion.div\n            key={i}\n            variants={variant}\n            transition={{ duration: 1.4, ease: [0.16, 1, 0.3, 1] }}\n            className=\"relative aspect-square overflow-hidden rounded-[16px]\"\n            style={{ background: t.imageBg }}\n          >\n            {/* eslint-disable-next-line @next/next/no-img-element */}\n            <img src={item.image} alt={item.caption || \"\"} loading=\"lazy\" className=\"block h-full w-full object-cover\" />\n          </motion.div>\n        ))}\n      </motion.div>\n\n      {showOverlay && (\n        <motion.div\n          initial={{ ...variant.hidden, x: \"-50%\", y: \"-50%\" }}\n          whileInView={{ ...variant.show, x: \"-50%\", y: \"-50%\" }}\n          viewport={{ once: true, amount: 0.1 }}\n          transition={{ duration: 1.4, ease: [0.16, 1, 0.3, 1], delay: 0.25 }}\n          className={cn(\"absolute top-1/2 left-1/2 z-10 flex w-max flex-col items-center gap-4.5 overflow-hidden rounded-[40px] border text-center backdrop-blur-2xl\", isMobile ? \"max-w-[85%] px-7 py-9\" : \"max-w-[420px] px-11 py-12\")}\n          style={{ background: t.overlayBg, borderColor: t.overlayBorder, boxShadow: theme === \"dark\" ? \"0 20px 60px rgba(0,0,0,0.5)\" : \"0 16px 48px rgba(0,0,0,0.1)\" }}\n        >\n          <div\n            aria-hidden=\"true\"\n            className=\"pointer-events-none absolute inset-0\"\n            style={{ backgroundImage: NOISE_BG, backgroundSize: \"140px 140px\", mixBlendMode: \"overlay\", opacity: theme === \"dark\" ? 0.07 : 0.04 }}\n          />\n          <h2 id={titleId} className=\"m-0 text-[48px] leading-[1.15] font-medium tracking-[-0.03em] whitespace-pre-line\" style={{ color: t.title }}>\n            {title}\n          </h2>\n          {subtitle && (\n            <p className=\"m-0 max-w-[320px] text-[15px] leading-[1.5]\" style={{ color: t.subtitle }}>\n              {subtitle}\n            </p>\n          )}\n          {buttonText && (\n            <a\n              href={buttonLink}\n              className=\"inline-flex items-center justify-center rounded-full px-6 py-3 text-sm font-medium tracking-[0.02em] no-underline transition-transform hover:scale-[1.04]\"\n              style={{ background: t.buttonBg, color: t.buttonText }}\n            >\n              {buttonText}\n            </a>\n          )}\n        </motion.div>\n      )}\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}