{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stats-cards",
  "type": "registry:block",
  "title": "Stats, cards",
  "description": "Two to four stat cards, each with a large value, a label, a line of context and an optional change badge.",
  "categories": [
    "stats"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/badge.json",
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-c-proof.json"
  ],
  "files": [
    {
      "path": "src/blocks/stats-cards/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/stats-cards/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, t } from '../_shared/schema';\n\nconst schema = z.object({\n  title: t(120),\n  description: t(300),\n  // 'centered' centres the header and draws each card as a large figure over its label (no context line or change badge), with the actions in a row under the cards; unset keeps the framed left-set cards.\n  look: z.enum(['centered']).optional(),\n  // Optional primary and secondary buttons; an empty label draws nothing.\n  actions: z.object({ primary: link.partial().optional(), secondary: link.partial().optional() }).optional(),\n  items: z.array(z.object({ value: t(16), label: t(40), description: t(160), delta: t(32) })).min(2).max(4),\n});\n\nexport const spec = defineSpec({\n  type: 'stats-cards',\n  aliases: ['stats/cards'],\n  sourceRuns: ['rmwj0w9qnf1f35e'],\n  name: 'Stats, cards',\n  category: 'stats',\n  role: 'body',\n  description: 'Two to four stat cards, each with a large value, a label, a line of context and an optional change badge.',\n  schema,\n  defaults: {\n    title: 'Say what changed over the period',\n    description: 'Say what changed for the reader after a period of using it.',\n    items: [\n      { value: '00%', label: 'Name the first result', description: 'Say how the first result is measured.', delta: '+00 pts' },\n      { value: '0.0 h', label: 'Name the second result', description: 'Say how the second result is measured.', delta: '−00%' },\n      { value: '00%', label: 'Name the third result', description: 'Say how the third result is measured.', delta: '+0 pts' },\n      { value: '00', label: 'Name the fourth count', description: 'Say who the fourth count covers.', delta: '' },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/stats-cards/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/stats-cards/index.tsx",
      "content": "import { ActionLink, Container, Section, useEditing } from '../_shared/kit';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { Heading, useHeadingId } from '../_shared/c-proof-kit';\nimport { Badge } from '../../ui/badge';\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 COLS = { 2: '@2xl:grid-cols-2', 3: '@2xl:grid-cols-2 @4xl:grid-cols-3', 4: '@2xl:grid-cols-2 @4xl:grid-cols-4' } as const;\n\nfunction StatsCards({ props }: BlockProps<Props>) {\n  const id = useHeadingId(props.title);\n  const editing = useEditing();\n  const n = Math.min(4, Math.max(2, props.items.length)) as 2 | 3 | 4;\n  if (props.look === 'centered') {\n    return (\n      <Section labelledBy={id}>\n        <Container className=\"flex flex-col gap-12 @3xl:gap-16\">\n          <Heading id={id} title={props.title} description={props.description} align=\"center\" />\n          <dl className={`grid gap-6 ${n === 2 ? '@2xl:grid-cols-2' : n === 3 ? '@2xl:grid-cols-3' : '@2xl:grid-cols-2 @4xl:grid-cols-4'}`}>\n            {props.items.map((item, i) => (\n              <div key={i} className=\"flex flex-col-reverse justify-end gap-3 rounded-kh-xl border border-kh-line bg-kh-surface p-8 shadow-kh-1\">\n                <dt className=\"text-kh-small text-kh-muted\">\n                  <Text path={['items', i, 'label']} value={item.label} as=\"span\" />\n                </dt>\n                <dd>\n                  <Text path={['items', i, 'value']} value={item.value} as=\"span\" className=\"text-kh-display font-semibold tabular-nums\" />\n                </dd>\n              </div>\n            ))}\n          </dl>\n          {props.actions && (\n            <div className=\"flex flex-col items-center justify-center gap-3 @md:flex-row\">\n              <ActionLink path={['actions', 'primary']} value={{ label: props.actions.primary?.label ?? '', href: props.actions.primary?.href ?? '' }} size=\"md\" />\n              <ActionLink path={['actions', 'secondary']} value={{ label: props.actions.secondary?.label ?? '', href: props.actions.secondary?.href ?? '' }} variant=\"secondary\" size=\"md\" />\n            </div>\n          )}\n        </Container>\n      </Section>\n    );\n  }\n  return (\n    <Section labelledBy={id}>\n      <Container>\n        <Heading id={id} title={props.title} description={props.description} />\n        <dl className={`mt-14 grid gap-4 ${COLS[n]}`}>\n          {props.items.map((item, i) => (\n            <div key={i} className=\"flex flex-col rounded-kh-xl border border-kh-line bg-kh-surface p-7\">\n              <dt className=\"text-kh-small font-medium text-kh-muted\">\n                <Text path={['items', i, 'label']} value={item.label} as=\"span\" />\n              </dt>\n              <dd className=\"mt-6 flex flex-wrap items-center gap-x-3 gap-y-2\">\n                <Text path={['items', i, 'value']} value={item.value} as=\"span\" className=\"text-kh-title font-semibold tabular-nums\" />\n                {(item.delta || editing) && (\n                  <Badge tone=\"accent\">\n                    <Text path={['items', i, 'delta']} value={item.delta} as=\"span\" placeholder=\"Change\" />\n                  </Badge>\n                )}\n              </dd>\n              <dd className=\"mt-3 text-kh-small text-kh-muted\">\n                <Text path={['items', i, 'description']} value={item.description} as=\"span\" />\n              </dd>\n            </div>\n          ))}\n        </dl>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(StatsCards);\n"
    }
  ]
}
