{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gallery-grid",
  "type": "registry:block",
  "title": "Gallery, grid",
  "description": "A grid of images with captions under a heading, filled row by row. columns \"2\" keeps pairs side by side, such as before and after. Give items a price and a note to show things for sale.",
  "categories": [
    "gallery"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json"
  ],
  "files": [
    {
      "path": "src/blocks/gallery-grid/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/gallery-grid/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, media, t } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  /** How many across on a wide screen. '2' keeps pairs (before and after) side by side; default '3'. */\n  columns: z.enum(['2', '3']).optional(),\n  /** Up to two actions in the header row, at the end beside the heading (under it on a narrow container): the first a filled button, the second an outlined one. Empty: no action row. */\n  actions: z.array(link).max(2).optional(),\n  /** Square pictures in a tight grid that stays three across at every width, with the caption small under each. Empty: 4 / 3 pictures that stack to one column on a narrow container. */\n  tiles: z.boolean().optional(),\n  /** price and note are optional: set them to show things for sale (a bike, a bouquet, a cake) with the caption as the name. */\n  /** caption t(500) (a real Instagram caption on Brewski, Vete-Katten and Tiptapp runs to 500 characters) and note t(300); href makes the picture a link (the post, the product page); up to 24 items (Brewski's feed). */\n  items: z.array(z.object({ media, caption: t(500), price: t(30).optional(), note: t(300).optional(), href: t(300).optional() })).min(1).max(24),\n});\n\nexport const spec = defineSpec({\n  type: 'gallery-grid',\n  aliases: ['gallery/grid'],\n  sourceRuns: ['rmwj1d6l7b306b1', 'rmwj1d6lae011dd'],\n  name: 'Gallery, grid',\n  category: 'gallery',\n  role: 'body',\n  description: 'A grid of images with captions under a heading, filled row by row. columns \"2\" keeps pairs side by side, such as before and after. Give items a price and a note to show things for sale.',\n  schema,\n  defaults: {\n    eyebrow: 'Name the topic',\n    title: 'Say what the pictures show',\n    description: 'Say in one line what the pictures show and where they were taken.',\n    items: [\n      { media: { src: '', alt: 'Show the subject of this picture, close' }, caption: 'Name the subject' },\n      { media: { src: '', alt: 'Show the subject of this picture, close' }, caption: 'Name the subject' },\n      { media: { src: '', alt: 'Show the subject of this picture, close' }, caption: 'Name the subject' },\n      { media: { src: '', alt: 'Show the subject, close' }, caption: 'Name the subject' },\n      { media: { src: '', alt: 'Show the subject of this picture, close' }, caption: 'Name the subject' },\n      { media: { src: '', alt: 'Show the subject of this picture, close' }, caption: 'Name the subject' },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/gallery-grid/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/gallery-grid/index.tsx",
      "content": "import { useId } from 'react';\nimport { Media, Text, withHeadingLevel } from '../../editing';\nimport { ActionLink, Container, Eyebrow, Opt, Section, SectionHeader } from '../_shared/kit';\nimport { safeHref } from '../../ui/button';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\nfunction GalleryGrid({ props }: BlockProps<Props>) {\n  const id = useId();\n  const ratio = props.tiles ? '1 / 1' : '4 / 3';\n  return (\n    <Section labelledBy={id}>\n      <Container>\n        {props.actions?.length ? (\n          <div className=\"flex flex-col gap-6 @3xl:flex-row @3xl:items-end @3xl:justify-between\">\n            <div className=\"max-w-kh-narrow\">\n              <Eyebrow path={['eyebrow']} value={props.eyebrow} />\n              <div id={id}>\n                <Text path={['title']} value={props.title} as=\"h2\" className=\"font-kh-display text-kh-heading\" />\n              </div>\n              <Opt path={['description']} value={props.description} multiline className=\"mt-4 whitespace-pre-line text-kh-lead text-kh-muted\" placeholder=\"Description\" />\n            </div>\n            <div className=\"flex flex-wrap gap-3\">\n              {props.actions.map((a, i) => <ActionLink key={i} path={['actions', i]} value={a} variant={i === 0 ? 'primary' : 'secondary'} />)}\n            </div>\n          </div>\n        ) : (\n          <SectionHeader id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        )}\n        <ul className={props.tiles ? 'mt-12 grid grid-cols-3 gap-2 @lg:gap-4 @4xl:gap-6' : `mt-12 grid gap-x-5 gap-y-8 @lg:grid-cols-2 ${props.columns === '2' ? '' : '@4xl:grid-cols-3'}`}>\n          {props.items.map((item, i) => (\n            <li key={i} className=\"min-w-0\">\n              <figure className=\"m-0\">\n                {item.href ? (\n                  <a href={safeHref(item.href)} className=\"block rounded-kh-lg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)\">\n                    <Media path={['items', i, 'media']} value={item.media} ratio={ratio} className=\"rounded-kh-lg border border-kh-line\" />\n                  </a>\n                ) : (\n                  <Media path={['items', i, 'media']} value={item.media} ratio={ratio} className=\"rounded-kh-lg border border-kh-line\" />\n                )}\n                {item.price === undefined && item.note === undefined ? (\n                  <Opt path={['items', i, 'caption']} value={item.caption} as=\"figcaption\" className=\"mt-3 max-w-prose text-kh-small text-kh-muted [overflow-wrap:anywhere]\" placeholder=\"Caption\" />\n                ) : (\n                  // For sale: the caption is the name, the price sits on the same line, the note under it.\n                  <figcaption className=\"mt-3\">\n                    <div className=\"flex items-baseline justify-between gap-4\">\n                      <Opt path={['items', i, 'caption']} value={item.caption} as=\"span\" className=\"min-w-0 text-kh-body font-medium text-kh-ink\" placeholder=\"Name\" />\n                      <Opt path={['items', i, 'price']} value={item.price} as=\"span\" className=\"shrink-0 text-kh-body font-medium tabular-nums text-kh-ink\" placeholder=\"Price\" />\n                    </div>\n                    <Opt path={['items', i, 'note']} value={item.note} as=\"p\" className=\"mt-1 text-kh-small text-kh-muted\" placeholder=\"One line about it\" />\n                  </figcaption>\n                )}\n              </figure>\n            </li>\n          ))}\n        </ul>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(GalleryGrid);\n"
    }
  ]
}
