{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"photo-fan","type":"registry:ui","title":"Photo Fan","description":"A fanned stack of photo cards that bounce into place when scrolled into view and spread apart on hover.","dependencies":["motion"],"registryDependencies":[],"files":[{"path":"registry/ui/photo-fan.tsx","type":"registry:ui","content":"\"use client\";\n/* eslint-disable @next/next/no-img-element */\n\nimport { useRef, useState } from \"react\";\nimport { motion, useInView, useReducedMotion } from \"motion/react\";\n\nexport interface PhotoFanProps {\n  images: string[];\n  /** Card width in px (height is 1.25x). */\n  cardSize?: number;\n  /** Px between neighbouring card centers. */\n  overlap?: number;\n  /** Degrees of fan rotation per card. */\n  rotation?: number;\n  /** Px the other cards are pushed away on hover. */\n  spread?: number;\n  /** Seconds between each card's entrance. */\n  stagger?: number;\n  /** Spring damping of the entrance, lower = bouncier. */\n  bounciness?: number;\n  className?: string;\n}\n\nexport function PhotoFan({\n  images,\n  cardSize = 170,\n  overlap = 110,\n  rotation = 7,\n  spread = 70,\n  stagger = 0.08,\n  bounciness = 9,\n  className,\n}: PhotoFanProps) {\n  const root = useRef<HTMLDivElement>(null);\n  const inView = useInView(root, { once: true, amount: 0.4 });\n  const reduce = useReducedMotion();\n  const [hovered, setHoveredState] = useState<number | null>(null);\n  // After the first hover the entrance delay is dropped so cards react instantly.\n  const [touched, setTouched] = useState(false);\n  const setHovered = (i: number | null) => {\n    setHoveredState(i);\n    if (i !== null) setTouched(true);\n  };\n  const mid = (images.length - 1) / 2;\n  const h = cardSize * 1.25;\n\n  return (\n    <div\n      ref={root}\n      role=\"list\"\n      className={`relative ${className ?? \"\"}`}\n      style={{ width: overlap * (images.length - 1) + cardSize + spread * 2, height: h + 60 }}\n      onPointerLeave={() => setHovered(null)}\n    >\n      {images.map((src, i) => {\n        const off = i - mid;\n        const push = hovered === null || hovered === i ? 0 : Math.sign(i - hovered) * spread;\n        const lifted = hovered === i;\n        const shown = inView || reduce;\n        return (\n          <motion.div\n            key={src + i}\n            role=\"listitem\"\n            tabIndex={0}\n            aria-label={`Photo ${i + 1} of ${images.length}`}\n            onPointerEnter={() => setHovered(i)}\n            onFocus={() => setHovered(i)}\n            onBlur={() => setHovered(null)}\n            className=\"absolute left-1/2 top-1/2 cursor-pointer overflow-hidden rounded-[18px] border-[5px] border-white bg-muted shadow-[0_18px_40px_-12px_rgba(0,0,0,.6)] outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n            style={{\n              width: cardSize,\n              height: h,\n              marginLeft: -cardSize / 2,\n              marginTop: -h / 2,\n              zIndex: lifted ? 50 : 10 - Math.round(Math.abs(off)),\n            }}\n            initial={reduce ? false : { scale: 0, opacity: 0 }}\n            animate={{\n              scale: shown ? (lifted ? 1.08 : 1) : 0,\n              opacity: shown ? 1 : 0,\n              x: off * overlap + push,\n              y: lifted ? -14 : Math.abs(off) * 6,\n              rotate: lifted ? 0 : off * rotation,\n            }}\n            transition={{\n              scale: touched\n                ? { type: \"spring\", stiffness: 300, damping: 18 }\n                : { type: \"spring\", stiffness: 260, damping: bounciness, delay: i * stagger },\n              opacity: { duration: 0.2, delay: i * stagger },\n              default: { type: \"spring\", stiffness: 260, damping: 22 },\n            }}\n          >\n            <img src={src} alt=\"\" draggable={false} className=\"size-full object-cover\" />\n          </motion.div>\n        );\n      })}\n    </div>\n  );\n}\n"}]}