{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "directory-cards",
  "type": "registry:block",
  "title": "Directory, cards",
  "description": "A heading and a grid of link cards with thumbnail, title, caption, meta and an optional tag or actions. Catalogue cards, groups with \"View all\", category and template grids.",
  "categories": [
    "directory"
  ],
  "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",
    "https://ui.klarhimmel.com/r/kit-b-directory.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/directory-cards/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/directory-cards/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, media, t, req } from '../_shared/schema';\n\n// KB-178: title 60 -> 100, description 160 -> 300, tag 16 -> 40; real descriptions run 135-215 chars.\nconst schema = z.object({\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  viewAll: link,\n  columns: z.enum(['2', '3', '4']),\n  items: z\n    .array(\n      z.object({\n        title: req(100),\n        description: t(300),\n        meta: t(60),\n        tag: t(40),\n        href: t(300),\n        media,\n        actions: z.array(link).max(2),\n      }),\n    )\n    .min(1)\n    .max(40),\n});\n\nexport const spec = defineSpec({\n  type: 'directory-cards',\n  aliases: ['directory/cards'],\n  name: 'Directory, cards',\n  category: 'directory',\n  role: 'body',\n  description: 'A heading and a grid of link cards with thumbnail, title, caption, meta and an optional tag or actions. Catalogue cards, groups with \"View all\", category and template grids.',\n  schema,\n  defaults: {\n    eyebrow: 'Name the section',\n    title: 'Say what the cards below let the reader choose',\n    description: 'Say in one or two sentences what the cards have in common and how a reader should pick one.',\n    viewAll: { label: 'Link to all', href: '/catalogue/' },\n    columns: '3',\n    items: [\n      { title: 'Name card one', description: 'Say what this card leads to, in a short line', meta: '00 items', tag: '', href: '/catalogue/components/', media: { src: '', alt: 'Show what the card leads to, in one clear picture' }, actions: [] },\n      { title: 'Name card two', description: 'Say what this card leads to, in a short line', meta: '00 items', tag: 'Tag', href: '/catalogue/blocks/', media: { src: '', alt: 'Show what the card leads to, in one clear picture' }, actions: [] },\n      { title: 'Name card three', description: 'Say what this card leads to, in a short line', meta: '00 items', tag: '', href: '/catalogue/app/', media: { src: '', alt: 'Show what the card leads to, in one clear picture' }, actions: [] },\n      { title: 'Name card four', description: 'Say what this card leads to, in a short line', meta: '00 items', tag: 'Tag', href: '/catalogue/agent/', media: { src: '', alt: 'Show what the card leads to, in one clear picture' }, actions: [] },\n      { title: 'Name card five', description: 'Say what this card leads to, in a short line', meta: '00 items', tag: '', href: '/catalogue/templates/', media: { src: '', alt: 'Show what the card leads to, in one clear picture' }, actions: [{ label: 'Main action', href: '/catalogue/templates/preview/' }, { label: 'Second action', href: '/catalogue/templates/download/' }] },\n      { title: 'Name card six', description: 'Say what this card leads to, in a short line', meta: '00 items', tag: '', href: '/catalogue/foundations/', media: { src: '', alt: 'Show what the card leads to, in one clear picture' }, actions: [] },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/directory-cards/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/directory-cards/index.tsx",
      "content": "import { useId } from 'react';\nimport { Media, Text, withHeadingLevel } from '../../editing';\nimport { cn } from '../../lib/utils';\nimport { safeHref } from '../../ui/button';\nimport { ActionLink, Container, Opt, Section, SectionHeader } from '../_shared/kit';\nimport { useHeaderEmpty } from '../_shared/b-directory-kit';\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\nconst COLUMNS: Record<Props['columns'], string> = {\n  '2': '@xl:grid-cols-2',\n  '3': '@xl:grid-cols-2 @4xl:grid-cols-3',\n  '4': '@xl:grid-cols-2 @4xl:grid-cols-3 @6xl:grid-cols-4',\n};\n\nfunction DirectoryCards({ props }: BlockProps<Props>) {\n  const id = useId();\n  const noHeader = useHeaderEmpty(props.eyebrow, props.title, props.description);\n  // Cards sit one level under the section title; without a title they are the page's h2s (no jump from h1 to h3).\n  const Card = noHeader ? 'h2' : 'h3';\n  return (\n    <Section labelledBy={noHeader ? undefined : id} className=\"py-10 @3xl:py-14\">\n      <Container>\n        {!noHeader && (\n          <div className=\"flex flex-col justify-between gap-6 @3xl:flex-row @3xl:items-end\">\n            <SectionHeader id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n            <ActionLink path={['viewAll']} value={props.viewAll} variant=\"secondary\" size=\"md\" className=\"self-start @3xl:self-auto\" />\n          </div>\n        )}\n        <ul className={cn('grid gap-5', !noHeader && 'mt-10', COLUMNS[props.columns])}>\n          {props.items.map((item, i) => (\n            <li key={i} className=\"min-w-0\">\n              <article className=\"group relative flex h-full flex-col rounded-kh-lg border border-kh-line bg-kh-surface p-3 transition-colors duration-(--kh-dur) hover:border-kh-line-strong\">\n                <Media path={['items', i, 'media']} value={item.media} ratio=\"16 / 10\" className=\"rounded-kh border border-kh-line\" priority={i < 3} />\n                <div className=\"flex flex-1 flex-col px-2 pb-2 pt-4\">\n                  <div className=\"flex items-start justify-between gap-3\">\n                    <Card className=\"text-kh-heading font-semibold\">\n                      <a href={safeHref(item.href)} className=\"rounded-kh-sm after:absolute after:inset-0 after:content-[''] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)\">\n                        <Text path={['items', i, 'title']} value={item.title} as=\"span\" />\n                      </a>\n                    </Card>\n                    <Opt path={['items', i, 'tag']} value={item.tag} as=\"span\" className=\"inline-flex shrink-0 items-center rounded-kh-pill bg-kh-accent-soft px-2.5 py-0.5 text-kh-caption font-medium text-kh-accent-ink\" placeholder=\"Tag\" />\n                  </div>\n                  <Text path={['items', i, 'description']} value={item.description} as=\"p\" className=\"mt-1.5 text-kh-small text-kh-muted\" />\n                  <Opt path={['items', i, 'meta']} value={item.meta} className=\"mt-4 text-kh-caption text-kh-muted\" placeholder=\"Meta\" />\n                  {item.actions.length > 0 && (\n                    <div className=\"relative z-10 mt-4 flex flex-wrap gap-2\">\n                      {item.actions.map((a, j) => (\n                        <ActionLink key={j} path={['items', i, 'actions', j]} value={a} variant=\"secondary\" size=\"sm\" />\n                      ))}\n                    </div>\n                  )}\n                </div>\n              </article>\n            </li>\n          ))}\n        </ul>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(DirectoryCards);\n"
    }
  ]
}
