{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "image-collage",
  "title": "Image collage",
  "description": "A responsive image collage with proportionate widths, aligned image heights and captions. Every row fills the available width.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/items/image-collage/image-collage.tsx",
      "content": "/* eslint-disable @next/next/no-img-element -- This portable image board accepts ordinary image URLs. */\n\"use client\";\n\nimport { useState, type CSSProperties } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type CollageImage = { src: string; alt: string; caption?: string; description?: string; href?: string; fit?: \"contain\" | \"cover\"; aspectRatio?: string };\n\nfunction suppliedRatio(value?: string): number | undefined {\n  if (!value) return;\n  const [width, height = 1] = value.split(\"/\").map(Number);\n  const ratio = width / height;\n  return Number.isFinite(ratio) && ratio > 0 ? ratio : undefined;\n}\n\nexport function ImageCollage({ images, columns = 2, gap = 12, showCaptions = true, className }: {\n  images: CollageImage[];\n  columns?: number;\n  gap?: number;\n  showCaptions?: boolean;\n  className?: string;\n}) {\n  const [measuredRatios, setMeasuredRatios] = useState<Record<string, number>>({});\n  const perRow = Number.isFinite(columns) ? Math.max(1, Math.min(4, Math.round(columns))) : 2;\n  const rows = Array.from({ length: Math.ceil(images.length / perRow) }, (_, index) => images.slice(index * perRow, (index + 1) * perRow));\n  const ratioFor = (image: CollageImage) => suppliedRatio(image.aspectRatio) ?? measuredRatios[image.src] ?? 4 / 3;\n\n  return (\n    <div className={cn(\"grid w-full font-body\", className)} style={{ gap }}>\n      {rows.map((row) => (\n        <div key={row[0].src} data-collage-row className=\"grid grid-cols-1 items-start sm:grid-cols-(--collage-row)\" style={{ \"--collage-row\": row.map((image) => `${ratioFor(image)}fr`).join(\" \"), gap } as CSSProperties}>\n          {row.map((image) => (\n            <figure key={image.src} className=\"min-w-0\">\n              <a href={image.href ?? image.src} target=\"_blank\" rel=\"noopener noreferrer\" aria-label={`Open ${image.alt} (opens in a new tab)`} className=\"block focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring\">\n                <img src={image.src} alt={image.alt} loading=\"lazy\" width={600} height={450} className={cn(\"h-auto w-full\", image.fit === \"cover\" ? \"object-cover\" : \"object-contain\")}\n                  style={{ aspectRatio: ratioFor(image) }}\n                  onLoad={(event) => {\n                    const { naturalWidth, naturalHeight } = event.currentTarget;\n                    if (suppliedRatio(image.aspectRatio) || !naturalHeight) return;\n                    const ratio = naturalWidth / naturalHeight;\n                    setMeasuredRatios((current) => current[image.src] === ratio ? current : { ...current, [image.src]: ratio });\n                  }} />\n              </a>\n              {showCaptions ? <figcaption className=\"pt-2 pb-1 text-[12px] leading-5\">\n                <span className=\"block text-ink\">{image.caption ?? image.alt}</span>\n                {image.description ? <span className=\"block text-dim\">{image.description}</span> : null}\n              </figcaption> : null}\n            </figure>\n          ))}\n        </div>\n      ))}\n    </div>\n  );\n}\n",
      "type": "registry:block"
    }
  ],
  "meta": {
    "kind": "pattern",
    "whenToUse": "Use to show school, employer or project images upright without decorative framing. Images share a height within each row, and a final single image fills the row. Supply aspect ratios for stable layout before loading, plus optional captions and descriptions.",
    "origin": {
      "project": "Portfolio",
      "path": "src/app/page.tsx (education, experience and project imagery; composed into a collage for bash-ui)"
    },
    "credits": []
  },
  "type": "registry:block"
}
