{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"review-cards-photos","type":"registry:component","title":"Review cards · Photo review","description":"Review with a drawn photo strip; a thumbnail grows into an in-card viewer with arrow keys and Escape.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/review-cards/photos.tsx","type":"registry:component","target":"components/examples/review-cards/photos.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { BadgeCheck, ChevronLeft, ChevronRight, Star, X } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface ReviewPhoto {\n  alt: string;\n  /** Real image URL. When omitted a drawn placeholder scene is used. */\n  src?: string;\n  /** Placeholder scene and its three tones (background, surface, object). */\n  scene?: \"still\" | \"detail\" | \"stack\" | \"window\";\n  tones?: [string, string, string];\n}\n\nexport interface PhotoReviewCardProps {\n  author?: string;\n  initials?: string;\n  date?: string;\n  rating?: number;\n  title?: string;\n  body?: string;\n  photos?: ReviewPhoto[];\n  className?: string;\n}\n\nconst DEFAULT_PHOTOS: ReviewPhoto[] = [\n  { alt: \"Mug on an oak table in morning light\", scene: \"still\", tones: [\"#d8cdbd\", \"#a98a66\", \"#3f4b41\"] },\n  { alt: \"Close-up of the speckled glaze\", scene: \"detail\", tones: [\"#33403a\", \"#56665b\", \"#e7dfd1\"] },\n  { alt: \"Three mugs stacked on a shelf\", scene: \"stack\", tones: [\"#e9e3d8\", \"#c8bba6\", \"#4a5a4e\"] },\n  { alt: \"Mug by a window with steam rising\", scene: \"window\", tones: [\"#bfae96\", \"#efe8dc\", \"#2e3a32\"] },\n];\n\nconst focus = \"outline-none focus-visible:shadow-[var(--focus-ring)]\";\nconst ctl = cn(\"grid size-8 place-items-center rounded-full border border-border bg-surface text-ink hover:border-border-strong\", focus);\n\nfunction Scene({ photo }: { photo: ReviewPhoto }) {\n  if (photo.src) {\n    // eslint-disable-next-line @next/next/no-img-element\n    return <img src={photo.src} alt=\"\" className=\"size-full object-cover\" />;\n  }\n  const [bg, mid, obj] = photo.tones ?? [\"#d8cdbd\", \"#a98a66\", \"#3f4b41\"];\n  return (\n    <svg viewBox=\"0 0 120 120\" preserveAspectRatio=\"xMidYMid slice\" className=\"size-full\" aria-hidden>\n      <rect width=\"120\" height=\"120\" fill={bg} />\n      {photo.scene === \"detail\" ? (\n        <>\n          <circle cx=\"60\" cy=\"60\" r=\"70\" fill={mid} />\n          {[[30, 34, 3], [72, 28, 2], [88, 66, 4], [44, 80, 2.5], [64, 54, 1.8], [20, 70, 2], [96, 98, 3]].map(([x, y, r], i) => (\n            <circle key={i} cx={x} cy={y} r={r} fill={obj} opacity={0.85} />\n          ))}\n          <path d=\"M0 96c20-8 40 6 60-2s40-10 60 0v26H0z\" fill={bg} opacity={0.6} />\n        </>\n      ) : photo.scene === \"stack\" ? (\n        <>\n          <rect y=\"84\" width=\"120\" height=\"36\" fill={mid} />\n          {[0, 1, 2].map((i) => (\n            <g key={i} transform={`translate(${30 + i * 4} ${74 - i * 18})`}>\n              <rect width=\"44\" height=\"20\" rx=\"4\" fill={obj} opacity={1 - i * 0.18} />\n              <ellipse cx=\"22\" cy=\"1\" rx=\"22\" ry=\"3\" fill={bg} opacity={0.35} />\n            </g>\n          ))}\n        </>\n      ) : photo.scene === \"window\" ? (\n        <>\n          <rect x=\"62\" y=\"10\" width=\"46\" height=\"62\" rx=\"2\" fill={mid} />\n          <path d=\"M85 10v62M62 41h46\" stroke={bg} strokeWidth=\"2\" />\n          <rect y=\"88\" width=\"120\" height=\"32\" fill={obj} opacity={0.25} />\n          <path d=\"M28 60h34v26a8 8 0 0 1-8 8H36a8 8 0 0 1-8-8z\" fill={obj} />\n          <path d=\"M62 66h4a7 7 0 0 1 0 14h-4\" fill=\"none\" stroke={obj} strokeWidth=\"3.5\" />\n          <path d=\"M40 52c-4-6 4-8 0-14M50 52c-4-6 4-8 0-14\" fill=\"none\" stroke={mid} strokeWidth=\"2\" strokeLinecap=\"round\" opacity={0.8} />\n        </>\n      ) : (\n        <>\n          <rect y=\"78\" width=\"120\" height=\"42\" fill={mid} />\n          <ellipse cx=\"58\" cy=\"92\" rx=\"30\" ry=\"5\" fill={obj} opacity={0.25} />\n          <path d=\"M38 48h40v34a10 10 0 0 1-10 10H48a10 10 0 0 1-10-10z\" fill={obj} />\n          <path d=\"M78 56h5a9 9 0 0 1 0 18h-5\" fill=\"none\" stroke={obj} strokeWidth=\"4\" />\n          <rect x=\"38\" y=\"48\" width=\"40\" height=\"5\" fill={bg} opacity={0.25} />\n        </>\n      )}\n    </svg>\n  );\n}\n\n/** Review with a drawn photo strip: tap a thumbnail and it grows into a viewer inside the card, with arrow keys and Escape. */\nexport function PhotoReviewCard({\n  author = \"Ines Duarte\",\n  initials = \"ID\",\n  date = \"Sep 30, 2026\",\n  rating = 5,\n  title = \"Glaze looks even better in person\",\n  body = \"Ordered four in moss. Each one is slightly different, which I love. They hold heat well and the handle fits two fingers comfortably.\",\n  photos = DEFAULT_PHOTOS,\n  className,\n}: PhotoReviewCardProps) {\n  const reduce = useReducedMotion() ?? false;\n  const [open, setOpen] = React.useState<number | null>(null);\n  const baseId = React.useId();\n  const viewerRef = React.useRef<HTMLDivElement>(null);\n  const thumbs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const spring = reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 340, damping: 32 };\n\n  React.useEffect(() => {\n    if (open !== null) viewerRef.current?.focus();\n  }, [open]);\n\n  function close() {\n    const i = open;\n    setOpen(null);\n    if (i !== null) requestAnimationFrame(() => thumbs.current[i]?.focus());\n  }\n\n  function step(d: number) {\n    setOpen((o) => (o === null ? o : (o + d + photos.length) % photos.length));\n  }\n\n  return (\n    <article className={cn(\"relative w-full max-w-[420px] overflow-hidden rounded-xl border border-border bg-surface-raised p-5 shadow-sm\", className)}>\n      <header className=\"flex items-center gap-3\">\n        <span aria-hidden className=\"grid size-9 place-items-center rounded-full bg-surface-sunken font-mono text-[11px] font-semibold text-ink\">\n          {initials}\n        </span>\n        <div className=\"min-w-0 flex-1\">\n          <p className=\"text-sm font-semibold text-ink\">{author}</p>\n          <p className=\"inline-flex items-center gap-1 text-[11.5px] text-success\">\n            <BadgeCheck aria-hidden className=\"size-3.5\" />\n            Verified buyer <span className=\"text-ink-subtle\">· {date}</span>\n          </p>\n        </div>\n        <span className=\"flex gap-px\" role=\"img\" aria-label={`${rating} out of 5`}>\n          {Array.from({ length: 5 }, (_, s) => (\n            <Star key={s} aria-hidden className={cn(\"size-3.5\", s < rating ? \"text-volt-ink\" : \"text-ink-subtle/35\")} fill=\"currentColor\" strokeWidth={0} />\n          ))}\n        </span>\n      </header>\n      <h3 className=\"mt-4 text-[15px] font-semibold text-ink\">{title}</h3>\n      <p className=\"mt-1 text-[13.5px] leading-relaxed text-ink-muted\">{body}</p>\n\n      <ul aria-label={`${photos.length} photos`} className=\"mt-4 grid grid-cols-4 gap-2\">\n        {photos.map((p, i) => (\n          <li key={i}>\n            <motion.button\n              ref={(el) => {\n                thumbs.current[i] = el;\n              }}\n              type=\"button\"\n              aria-label={`Open photo ${i + 1}: ${p.alt}`}\n              onClick={() => setOpen(i)}\n              whileHover={reduce ? undefined : { y: -2 }}\n              whileTap={reduce ? undefined : { scale: 0.96 }}\n              className={cn(\"block aspect-square w-full overflow-hidden rounded-md\", focus)}\n            >\n              {open !== i ? (\n                <motion.span layoutId={`${baseId}-p${i}`} transition={spring} className=\"block size-full overflow-hidden rounded-md\">\n                  <Scene photo={p} />\n                </motion.span>\n              ) : (\n                <span className=\"block size-full rounded-md bg-surface-sunken\" />\n              )}\n            </motion.button>\n          </li>\n        ))}\n      </ul>\n\n      <AnimatePresence>\n        {open !== null && (\n          <motion.div\n            ref={viewerRef}\n            role=\"dialog\"\n            aria-label={`Photo ${open + 1} of ${photos.length}`}\n            tabIndex={-1}\n            onKeyDown={(e) => {\n              if (e.key === \"Escape\") close();\n              if (e.key === \"ArrowRight\") step(1);\n              if (e.key === \"ArrowLeft\") step(-1);\n            }}\n            className=\"absolute inset-0 z-10 flex flex-col p-3 outline-none\"\n          >\n            <motion.div aria-hidden initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} className=\"absolute inset-0 bg-surface-raised\" />\n            <motion.div key={open} layoutId={`${baseId}-p${open}`} transition={spring} className=\"relative min-h-0 flex-1 overflow-hidden rounded-lg shadow-lg\">\n              <Scene photo={photos[open]} />\n            </motion.div>\n            <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} className=\"relative mt-2 flex items-center gap-2\">\n              <p className=\"min-w-0 flex-1 truncate text-xs text-ink-muted\">{photos[open].alt}</p>\n              <span className=\"font-mono text-[11px] text-ink-subtle\">\n                {open + 1}/{photos.length}\n              </span>\n              <button type=\"button\" aria-label=\"Previous photo\" onClick={() => step(-1)} className={ctl}>\n                <ChevronLeft aria-hidden className=\"size-4\" />\n              </button>\n              <button type=\"button\" aria-label=\"Next photo\" onClick={() => step(1)} className={ctl}>\n                <ChevronRight aria-hidden className=\"size-4\" />\n              </button>\n              <button type=\"button\" aria-label=\"Close photo\" onClick={close} className={ctl}>\n                <X aria-hidden className=\"size-4\" />\n              </button>\n            </motion.div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </article>\n  );\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["examples","reviews","rating","stars","testimonial","ecommerce","feedback","histogram","card"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/review-cards#photos"}}