{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stats-columns",
  "type": "registry:block",
  "title": "Stats, columns",
  "description": "A heading on the left with a short note on the right, then three to eight vertical bars on a baseline, each with its value above and its label under. The bar height is the first number in `value`, scaled so the largest fills the chart; use it for a week or a few periods. On a phone the heading and note stack and the bars keep their row, narrower.",
  "categories": [
    "stats"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-app.json",
    "https://ui.klarhimmel.com/r/kit-c-proof.json"
  ],
  "files": [
    {
      "path": "src/blocks/stats-columns/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/stats-columns/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  title: t(80),\n  note: t(80),\n  /** A list is an array field, never a slot. */\n  items: z.array(z.object({\n    label: req(20),\n    /** The number above the bar, written as text. Its first number sets the bar height against the largest in the list. */\n    value: req(20),\n  })).min(3).max(8),\n});\n\nexport const spec = defineSpec({\n  type: 'stats-columns',\n  aliases: ['stats/columns'],\n  name: 'Stats, columns',\n  category: 'stats',\n  role: 'body',\n  description: 'A heading on the left with a short note on the right, then three to eight vertical bars on a baseline, each with its value above and its label under. The bar height is the first number in `value`, scaled so the largest fills the chart; use it for a week or a few periods. On a phone the heading and note stack and the bars keep their row, narrower.',\n  schema,\n  defaults: {\n    title: 'Say what the bars measure over time',\n    note: 'Say in a few words the period and the unit.',\n    items: [\n      { label: 'Name 1', value: '70' },\n      { label: 'Name 2', value: '64' },\n      { label: 'Name 3', value: '58' },\n      { label: 'Name 4', value: '52' },\n      { label: 'Name 5', value: '46' },\n      { label: 'Name 6', value: '40' },\n      { label: 'Name 7', value: '34' },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/stats-columns/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/stats-columns/index.tsx",
      "content": "import { Text, withHeadingLevel } from '../../editing';\nimport { Container, Section } from '../_shared/kit';\nimport { useHeadingId } from '../_shared/c-proof-kit';\nimport { parseAmount } from '../_shared/app-kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\nconst HEIGHT = ['h-[0%]', 'h-[5%]', 'h-[10%]', 'h-[15%]', 'h-[20%]', 'h-[25%]', 'h-[30%]', 'h-[35%]', 'h-[40%]', 'h-[45%]', 'h-[50%]', 'h-[55%]', 'h-[60%]', 'h-[65%]', 'h-[70%]', 'h-[75%]', 'h-[80%]', 'h-[85%]', 'h-[90%]', 'h-[95%]', 'h-[100%]'];\n\ntype Props = z.infer<typeof spec.schema>;\n\n/** The number in `value`, never below 0; 0 when the text has no number. */\nconst amountOf = (value: string) => Math.max(0, parseAmount(value) ?? 0);\n\nfunction StatsColumns({ props }: BlockProps<Props>) {\n  const id = useHeadingId(props.title);\n  const amounts = props.items.map((it) => amountOf(it.value));\n  const max = Math.max(...amounts);\n  return (\n    <Section labelledBy={id}>\n      <Container>\n        <div className=\"flex flex-col gap-2 @md:flex-row @md:items-end @md:justify-between @md:gap-8\">\n          <div id={id}>\n            <Text path={['title']} value={props.title} as=\"h2\" className=\"text-kh-title font-semibold\" />\n          </div>\n          <Text path={['note']} value={props.note} as=\"p\" className=\"text-kh-small text-kh-muted\" />\n        </div>\n        <ul className=\"mt-10 flex gap-2 border-b border-kh-line @md:gap-4\">\n          {props.items.map((item, i) => (\n            <li key={i} className=\"flex h-64 min-w-0 flex-1 flex-col @md:h-96\">\n              {/* The bar's height is one of 21 literal classes (5 % steps of the largest value): no inline style (CSP style-src self). */}\n              <div className=\"mt-8 flex min-h-0 flex-1 flex-col items-center justify-end gap-2\">\n                <Text path={['items', i, 'value']} value={item.value} as=\"span\" className=\"h-6 shrink-0 text-kh-small tabular-nums @md:text-kh-body\" />\n                <div role=\"meter\" aria-label={item.label} aria-valuemin={0} aria-valuemax={max} aria-valuenow={amounts[i]} aria-valuetext={item.value} className={`w-3/5 shrink-0 bg-kh-accent ${HEIGHT[max ? Math.round((amounts[i]! / max) * 20) : 0]}`} />\n              </div>\n            </li>\n          ))}\n        </ul>\n        <ul className=\"mt-2 flex gap-2 @md:gap-4\" aria-hidden>\n          {props.items.map((item, i) => (\n            <li key={i} className=\"min-w-0 flex-1 text-center\">\n              <Text path={['items', i, 'label']} value={item.label} as=\"span\" className=\"text-kh-small @md:text-kh-body\" />\n            </li>\n          ))}\n        </ul>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(StatsColumns);\n"
    }
  ]
}
