{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stats-rings",
  "type": "registry:block",
  "title": "Stats, rings",
  "description": "Two to four percentages as rings with the figure in the middle, a label and a note under each. The fill is the number in `value` (0 to 100); a value with no number draws an empty ring. For rates and shares, not raw counts.",
  "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",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/stats-rings/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/stats-rings/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, req, t } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: req(120),\n  description: t(300),\n  items: z.array(z.object({\n    /** The number in the ring, as text: \"92%\" or \"4,5 %\". Its first number (0 to 100) is how much of the ring is filled. */\n    value: req(20),\n    label: req(60),\n    note: t(100),\n  })).min(2).max(4),\n});\n\nexport const spec = defineSpec({\n  type: 'stats-rings',\n  aliases: ['stats/rings'],\n  name: 'Stats, rings',\n  category: 'stats',\n  role: 'body',\n  description: 'Two to four percentages as rings with the figure in the middle, a label and a note under each. The fill is the number in `value` (0 to 100); a value with no number draws an empty ring. For rates and shares, not raw counts.',\n  schema,\n  defaults: {\n    eyebrow: 'Name the topic',\n    title: 'Say what a period of use looks like',\n    description: 'Say what the figures average over and who they cover.',\n    items: [\n      { value: '00%', label: 'Name the first measure', note: 'Say how it changed.' },\n      { value: '00%', label: 'Name the second measure', note: 'Say what it saved or lowered.' },\n      { value: '00%', label: 'Name the third measure', note: 'Say over what time.' },\n      { value: '00%', label: 'Name the fourth measure', note: 'Say when it counts.' },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/stats-rings/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/stats-rings/index.tsx",
      "content": "import { Text, withHeadingLevel } from '../../editing';\nimport { Container, Opt, Section } from '../_shared/kit';\nimport { Heading, useHeadingId } from '../_shared/c-proof-kit';\nimport { parseAmount } from '../_shared/app-kit';\nimport { cn } from '../../lib/utils';\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: '@xl:grid-cols-2', 3: '@xl:grid-cols-3', 4: '@xl:grid-cols-2 @4xl:grid-cols-4' } as const;\nconst percentOf = (value: string) => {\n  const n = parseAmount(value);\n  return n === null ? 0 : Math.min(100, Math.max(0, n));\n};\n\nfunction StatsRings({ props }: BlockProps<Props>) {\n  const id = useHeadingId(props.title);\n  const n = Math.min(4, Math.max(2, props.items.length)) as 2 | 3 | 4;\n  return (\n    <Section labelledBy={id}>\n      <Container>\n        <Heading id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        <ul className={cn('mt-14 grid gap-10', COLS[n])}>\n          {props.items.map((item, i) => {\n            const pct = percentOf(item.value);\n            return (\n              <li key={i} className=\"flex flex-col items-center text-center\">\n                <div className=\"relative size-40\">\n                  <svg viewBox=\"0 0 120 120\" aria-hidden className=\"size-full -rotate-90\">\n                    <circle cx=\"60\" cy=\"60\" r=\"52\" fill=\"none\" strokeWidth=\"10\" className=\"stroke-kh-surface-3\" />\n                    <circle cx=\"60\" cy=\"60\" r=\"52\" fill=\"none\" strokeWidth=\"10\" strokeLinecap=\"round\" pathLength={100} strokeDasharray={`${pct} ${100 - pct}`} className=\"stroke-kh-accent\" />\n                  </svg>\n                  <Text path={['items', i, 'value']} value={item.value} as=\"span\" className=\"absolute inset-0 flex items-center justify-center text-kh-title font-semibold tabular-nums\" />\n                </div>\n                <Text path={['items', i, 'label']} value={item.label} as=\"h3\" className=\"mt-6 text-kh-body font-medium\" />\n                <Opt path={['items', i, 'note']} value={item.note} className=\"mt-1 max-w-56 text-kh-small text-kh-muted\" placeholder=\"Note\" />\n              </li>\n            );\n          })}\n        </ul>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(StatsRings);\n"
    }
  ]
}
