{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "features-grid",
  "type": "registry:block",
  "title": "Features, grid",
  "description": "Optional section heading and a grid of up to nine features, each with an optional icon, a title and a short description. Two to four columns.",
  "categories": [
    "features"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "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/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-c-proof.json",
    "https://ui.klarhimmel.com/r/text-link.json"
  ],
  "files": [
    {
      "path": "src/blocks/features-grid/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/features-grid/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, icon, link, media, t } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  /** Columns at the widest container: '2' | '3' | '4'. Unset = 3. */\n  columns: z.enum(['2', '3', '4']).optional(),\n  /** One wide picture between the heading and the grid (a product shot over the feature row: the study's headline, wide visual, feature columns; Framer, Stripe, Figma, Shopify). Unset draws none. */\n  media: media.optional(),\n  /** A text link under the heading block, and one button under the grid. */\n  headerLink: link.partial().optional(),\n  button: link.partial().optional(),\n  // Per item: a picture instead of the icon (a picture wins when both are set), a link under the text, up to 8 small tags (tetris-flytt, varnhems-cyklar, tiptapp).\n  items: z\n    .array(z.object({ icon: icon.optional(), image: media.optional(), link: link.partial().optional(), tags: z.array(t(40)).max(8).optional(), title: t(60), description: t(200) }))\n    .min(1)\n    .max(9),\n});\n\nexport const spec = defineSpec({\n  type: 'features-grid',\n  aliases: ['features/grid'],\n  name: 'Features, grid',\n  category: 'features',\n  role: 'body',\n  description: 'Optional section heading and a grid of up to nine features, each with an optional icon, a title and a short description. Two to four columns.',\n  schema,\n  defaults: {\n    columns: '3',\n    eyebrow: 'Name the section',\n    title: 'Say what the reader gets and what they do not need',\n    description: 'Say in one sentence what the features below have in common and who they are for.',\n    items: [\n      { icon: 'layers', title: 'Name feature one', description: 'Say what the first feature does for the reader, in one sentence.' },\n      { icon: 'zap', title: 'Name the second feature', description: 'Say what the second feature does for the reader, in one sentence.' },\n      { icon: 'shield', title: 'Name the third feature', description: 'Say what the third feature does for the reader, in one sentence.' },\n      { icon: 'users', title: 'Name the fourth feature', description: 'Say what the fourth feature does for the reader, in one sentence.' },\n      { icon: 'chart', title: 'Name the fifth feature', description: 'Say what the fifth feature does for the reader, in one sentence.' },\n      { icon: 'settings', title: 'Name the sixth feature', description: 'Say what the sixth feature does for the reader, in one sentence.' },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/features-grid/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/features-grid/index.tsx",
      "content": "import { Text, withHeadingLevel } from '../../editing';\nimport { Media } from '../../editing';\nimport { ActionLink, Container, HAIR_CELL, HAIR_GRID, HairFrame, Icon, Section, useEditing } from '../_shared/kit';\nimport { Badge } from '../../ui/badge';\nimport { ArrowUpRight } from 'lucide-react';\nimport { safeHref } from '../../ui/button';\nimport { linkClass } from '../../ui/text-link';\nimport { Heading, hasImage, useHeadingId } from '../_shared/c-proof-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 TWO = '@xl:grid-cols-2';\nconst THREE = '@xl:grid-cols-2 @4xl:grid-cols-3';\nconst THREE_EVEN = '@3xl:grid-cols-3'; // a multiple of three never passes through two columns, so no row ends short\nconst FOUR = '@xl:grid-cols-2 @4xl:grid-cols-4';\n\n/** Column classes for the requested count and the number of items: avoid layouts that leave a short last row where a neighbouring count fits. */\nfunction columnsFor(columns: '2' | '3' | '4', n: number): string {\n  const c = Math.min(Number(columns), n);\n  if (c <= 1) return '';\n  if (c === 2) return TWO;\n  if (c === 3) return n % 3 === 0 ? THREE_EVEN : THREE;\n  return n % 4 === 0 ? FOUR : n % 3 === 0 ? THREE_EVEN : FOUR;\n}\n\nfunction FeaturesGrid({ props }: BlockProps<Props>) {\n  const id = useHeadingId(props.title);\n  const hasHeading = !!(props.eyebrow || props.title || props.description);\n  const single = props.items.length === 1 && !useEditing();\n  const item = (it: Props['items'][number], i: number) => (\n    <>\n      {it.image && hasImage(it.image) && (\n        <Media path={['items', i, 'image']} value={it.image} ratio=\"4 / 3\" className=\"mb-5 rounded-kh-lg border border-kh-line\" />\n      )}\n      {it.icon && !(it.image && hasImage(it.image)) && (\n        <span className=\"mb-5 inline-flex size-10 items-center justify-center rounded-kh border border-kh-line bg-kh-surface text-kh-accent-ink\">\n          <Icon name={it.icon} />\n        </span>\n      )}\n      <Text path={['items', i, 'title']} value={it.title} as=\"h3\" className=\"text-kh-heading font-semibold\" />\n      <Text path={['items', i, 'description']} value={it.description} as=\"p\" className=\"mt-2 text-kh-body text-kh-muted\" />\n      {it.tags && it.tags.length > 0 && (\n        <ul className=\"mt-4 flex flex-wrap gap-2\">\n          {it.tags.map((tag, j) => <li key={j}><Badge><Text path={['items', i, 'tags', j]} value={tag} as=\"span\" /></Badge></li>)}\n        </ul>\n      )}\n      {it.link && it.link.label && (\n        <p className=\"mt-4\">\n          <a href={safeHref(it.link.href)} className={`${linkClass()} inline-flex min-h-6 items-center gap-1 text-kh-small font-medium no-underline`}>\n            <Text path={['items', i, 'link', 'label']} value={it.link.label} as=\"span\" />\n            <ArrowUpRight aria-hidden className=\"size-4\" />\n          </a>\n        </p>\n      )}\n    </>\n  );\n  return (\n    <Section labelledBy={id}>\n      <Container>\n        <Heading id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        {props.headerLink && props.headerLink.label && (\n          <p className=\"mt-4\">\n            <a href={safeHref(props.headerLink.href)} className={`${linkClass()} inline-flex min-h-6 items-center gap-1 text-kh-small font-medium no-underline`}>\n              <Text path={['headerLink', 'label']} value={props.headerLink.label} as=\"span\" />\n              <ArrowUpRight aria-hidden className=\"size-4\" />\n            </a>\n          </p>\n        )}\n        {props.media && <Media path={['media']} value={props.media} ratio=\"16 / 9\" className={`${hasHeading || props.headerLink?.label ? 'mt-14' : ''} rounded-kh-xl border border-kh-line`} />}\n        {/* One card in a wide frame reads as unfinished (launcher r8), so on a real page a lone item follows the lede unboxed. */}\n        {single ? (\n          <div className={hasHeading || props.media ? 'mt-10 max-w-kh-narrow' : 'max-w-kh-narrow'}>{item(props.items[0]!, 0)}</div>\n        ) : (\n          <HairFrame className={props.media ? 'mt-10' : hasHeading ? 'mt-14' : undefined}>\n            <ul className={`${HAIR_GRID} ${columnsFor(props.columns ?? '3', props.items.length)}`}>\n              {props.items.map((it, i) => (\n                <li key={i} className={`${HAIR_CELL} bg-kh-canvas p-8`}>{item(it, i)}</li>\n              ))}\n            </ul>\n          </HairFrame>\n        )}\n        {props.button && <div className=\"mt-10\"><ActionLink path={['button']} value={{ label: props.button.label ?? '', href: props.button.href ?? '' }} variant=\"secondary\" size=\"md\" /></div>}\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(FeaturesGrid);\n"
    }
  ]
}
