{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "review-summary",
  "type": "registry:block",
  "title": "Review, summary",
  "description": "The front of a site review: which site, when, how many pages were read, the verdict in a few plain sentences, up to five findings with a severity said in words and the page each is about, what we would build, and two actions (go ahead, ask a question). Fields left empty are hidden, never filled with sample text; src/review/map.ts fills them from a Canvas review record (docs/review-blocks.md).",
  "categories": [
    "review"
  ],
  "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-invalid.json",
    "https://ui.klarhimmel.com/r/text-link.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/review-summary/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/review-summary/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, req, t } from '../_shared/schema';\n\nconst action = z.object({ label: req(40), href: t(300) });\nconst SEVERITY = ['high', 'medium', 'low', 'good', ''] as const;\n\nconst schema = z.object({\n  eyebrow: t(60),\n  siteName: req(80),\n  siteUrl: t(200),\n  reviewedOn: t(40),\n  pagesRead: t(40),\n  verdictTitle: req(60),\n  /** The review's summary: two to four plain sentences for the customer (review.summary). */\n  verdict: t(600),\n  findingsTitle: req(60),\n  /** How each severity is said in words (never colour alone). */\n  severityWords: z.object({ high: req(24), medium: req(24), low: req(24), good: req(24) }),\n  /** The most important findings, first first (review.findings; the block shows up to five). */\n  findings: z.array(z.object({\n    title: req(100),\n    detail: t(400),\n    /** high | medium | low | good, or '' for none. */\n    severity: z.enum(SEVERITY),\n    /** The page it is about, by name; `pageHref` makes it a link. */\n    page: t(60),\n    pageHref: t(300),\n  })).max(5),\n  /** Said instead of the list when the review found nothing (a hidden list with no line would read as an error). */\n  noFindings: t(120),\n  buildTitle: req(60),\n  build: t(600),\n  buildPoints: z.array(t(100)).max(5),\n  goAhead: action,\n  question: action,\n  note: t(200),\n});\n\nexport const spec = defineSpec({\n  type: 'review-summary',\n  headingSlot: 'siteName',\n  aliases: ['review/summary'],\n  name: 'Review, summary',\n  category: 'review',\n  strict: true, // a real customer's review: invalid props show an invalid notice, never the sample copy\n  role: 'body',\n  description: 'The front of a site review: which site, when, how many pages were read, the verdict in a few plain sentences, up to five findings with a severity said in words and the page each is about, what we would build, and two actions (go ahead, ask a question). Fields left empty are hidden, never filled with sample text; src/review/map.ts fills them from a Canvas review record (docs/review-blocks.md).',\n  schema,\n  defaults: {\n    eyebrow: 'Name the topic',\n    siteName: 'Name the business',\n    siteUrl: 'https://exempel.example',\n    reviewedOn: '1 January 0000',\n    pagesRead: '00 pages read',\n    verdictTitle: 'Name the verdict',\n    verdict: 'Say in two or three sentences what the site does well, then name the few things that hold it back. Say what you would keep, what you would fix first, and why, in plain words a stranger can follow.',\n    findingsTitle: 'Name the findings',\n    severityWords: { high: 'Most urgent', medium: 'Less urgent', low: 'Optional', good: 'Going well' },\n    findings: [\n      { title: 'Say what the finding is, as a short title', detail: 'Say what a visitor runs into on the page, why it matters, and what one change would do about it.', severity: 'high', page: 'Name a page', pageHref: '' },\n      { title: 'Say what the finding is, as a short title', detail: 'Say what a visitor runs into on the page, why it matters to the business, and what one change would do about it.', severity: 'medium', page: 'Name a page', pageHref: '' },\n      { title: 'Say what the finding is, as a short title', detail: 'Say what a visitor runs into on a phone, and what one change would do about it.', severity: 'medium', page: 'Name a page', pageHref: '' },\n      { title: 'Say what the finding is, as a short title', detail: 'Say what works well on the page and why, and that you would keep it as it is.', severity: 'good', page: 'Name a page', pageHref: '' },\n    ],\n    noFindings: 'Say that nothing was found',\n    buildTitle: 'Name what you would build',\n    build: 'Say in two sentences what you would build for them, how long it takes, and what they can click through before anything goes live.',\n    buildPoints: ['Name a first thing you would build', 'Name a second thing you would build', 'Name a third thing you would build', 'Name a thing you would keep as it is'],\n    goAhead: { label: 'Main action', href: '#go-ahead' },\n    question: { label: 'Second action', href: '#question' },\n    note: 'Say what happens next and what waits for them',\n  },\n});\n"
    },
    {
      "path": "src/blocks/review-summary/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/review-summary/index.tsx",
      "content": "import { useId } from 'react';\nimport { ArrowUpRight, AlertTriangle, CircleCheck, Info, TriangleAlert } from 'lucide-react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { ButtonLink, safeHref } from '../../ui/button';\nimport { Badge } from '../../ui/badge';\nimport { linkClass } from '../../ui/text-link';\nimport { InvalidNotice } from '../_shared/invalid-kit';\nimport { Container, Eyebrow, Opt, Section, useEditing } from '../_shared/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\n// A severity is a word and a shape as well as a tone: nothing depends on colour alone.\nconst SEV = {\n  high: { Icon: TriangleAlert, tone: 'accent' as const },\n  medium: { Icon: AlertTriangle, tone: 'neutral' as const },\n  low: { Icon: Info, tone: 'outline' as const },\n  good: { Icon: CircleCheck, tone: 'outline' as const },\n};\n\nfunction ReviewSummary({ props }: BlockProps<Props>) {\n  // strict: invalid props are never replaced by the sample copy\n  if (!spec.schema.safeParse(props).success) return <InvalidNotice title=\"This review could not be shown\" />;\n  const id = useId();\n  const editing = useEditing();\n  const hasFindings = props.findings.length > 0;\n  const hasBuild = !!props.build || props.buildPoints.length > 0;\n  return (\n    <Section labelledBy={id}>\n      <Container width=\"narrow\" className=\"@4xl:max-w-kh-page\">\n        <Eyebrow path={['eyebrow']} value={props.eyebrow} />\n        <div id={id}>\n          <Text path={['siteName']} value={props.siteName} as=\"h2\" className=\"text-kh-title font-semibold\" />\n        </div>\n        <p className=\"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-kh-small text-kh-muted\">\n          {(props.siteUrl || editing) && (\n            <a href={safeHref(props.siteUrl)} className={cn(linkClass(), 'inline-flex min-h-6 items-center gap-1 break-all')}>\n              <Text path={['siteUrl']} value={props.siteUrl} as=\"span\" />\n              <ArrowUpRight aria-hidden className=\"size-3.5\" />\n            </a>\n          )}\n          <Opt path={['reviewedOn']} value={props.reviewedOn} as=\"span\" placeholder=\"Date\" />\n          <Opt path={['pagesRead']} value={props.pagesRead} as=\"span\" placeholder=\"Pages read\" />\n        </p>\n\n        {(props.verdict || editing) && (\n          <div className=\"mt-10 rounded-kh-xl border border-kh-line bg-kh-accent-soft p-7 @2xl:p-9\">\n            <Text path={['verdictTitle']} value={props.verdictTitle} as=\"h3\" className=\"text-kh-small font-medium text-kh-accent-ink\" />\n            <Opt path={['verdict']} value={props.verdict} multiline className=\"mt-3 max-w-kh-lead text-kh-lead leading-snug\" placeholder=\"Verdict\" />\n          </div>\n        )}\n\n        {(hasFindings || props.noFindings || editing) && (\n          <Text path={['findingsTitle']} value={props.findingsTitle} as=\"h3\" className=\"mt-12 text-kh-heading font-semibold\" />\n        )}\n        {editing && (\n          <p className=\"mt-2 flex flex-wrap gap-3 text-kh-caption text-kh-muted\">\n            {(['high', 'medium', 'low', 'good'] as const).map((k) => (\n              <Text key={k} path={['severityWords', k]} value={props.severityWords[k]} as=\"span\" />\n            ))}\n          </p>\n        )}\n        {((!hasFindings && props.noFindings) || editing) && (\n          <Opt path={['noFindings']} value={props.noFindings} className={cn('text-kh-muted', hasFindings ? 'mt-2 text-kh-caption' : 'mt-5 text-kh-body')} placeholder=\"Said when there are no findings\" />\n        )}\n        {hasFindings && <ol className=\"mt-5 divide-y divide-kh-line border-y border-kh-line\">\n          {props.findings.map((f, i) => {\n            const s = f.severity ? SEV[f.severity] : null;\n            return (\n              <li key={i} className=\"grid gap-x-8 gap-y-2 py-6 @3xl:grid-cols-[11rem_1fr]\">\n                <div className=\"flex flex-wrap items-start gap-2 @3xl:flex-col\">\n                  {s && f.severity && (\n                    <Badge tone={s.tone}>\n                      <s.Icon aria-hidden strokeWidth={1.75} className=\"mr-1 size-3.5\" />\n                      <Text path={['severityWords', f.severity]} value={props.severityWords[f.severity]} as=\"span\" />\n                    </Badge>\n                  )}\n                  {f.page && (\n                    f.pageHref ? (\n                      <a href={safeHref(f.pageHref)} className={cn(linkClass(), 'inline-flex min-h-6 items-center text-kh-small')}>\n                        <Text path={['findings', i, 'page']} value={f.page} as=\"span\" />\n                      </a>\n                    ) : (\n                      <Text path={['findings', i, 'page']} value={f.page} as=\"span\" className=\"text-kh-small text-kh-muted\" />\n                    )\n                  )}\n                </div>\n                <div>\n                  <Text path={['findings', i, 'title']} value={f.title} as=\"h4\" className=\"text-kh-body font-semibold\" />\n                  <Opt path={['findings', i, 'detail']} value={f.detail} multiline className=\"mt-1 max-w-kh-lead text-kh-small text-kh-muted\" placeholder=\"Detail\" />\n                </div>\n              </li>\n            );\n          })}\n        </ol>}\n\n        <div className=\"mt-12 grid gap-8 @3xl:grid-cols-[1.4fr_1fr] @3xl:gap-14\">\n          {(hasBuild || editing) && <div>\n            <Text path={['buildTitle']} value={props.buildTitle} as=\"h3\" className=\"text-kh-heading font-semibold\" />\n            <Opt path={['build']} value={props.build} multiline className=\"mt-3 max-w-kh-lead text-kh-body text-kh-muted\" placeholder=\"What we would build\" />\n            {props.buildPoints.length > 0 && (\n              <ul className=\"mt-4 space-y-2\">\n                {props.buildPoints.map((p, i) => (\n                  <li key={i} className=\"flex items-start gap-3 text-kh-small\">\n                    <CircleCheck aria-hidden strokeWidth={1.75} className=\"mt-0.5 size-4 shrink-0 text-kh-accent-ink\" />\n                    <Text path={['buildPoints', i]} value={p} as=\"span\" />\n                  </li>\n                ))}\n              </ul>\n            )}\n          </div>}\n          <div className=\"self-start rounded-kh-xl border border-kh-line bg-kh-surface p-6 shadow-kh-1\">\n            <div className=\"flex flex-wrap gap-3\">\n              <ButtonLink href={props.goAhead.href} size=\"md\">\n                <Text path={['goAhead', 'label']} value={props.goAhead.label} as=\"span\" />\n              </ButtonLink>\n              <ButtonLink href={props.question.href} variant=\"secondary\" size=\"md\">\n                <Text path={['question', 'label']} value={props.question.label} as=\"span\" />\n              </ButtonLink>\n            </div>\n            <Opt path={['note']} value={props.note} className=\"mt-4 text-kh-caption text-kh-muted\" placeholder=\"Note\" />\n          </div>\n        </div>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(ReviewSummary, 'siteName');\n"
    }
  ]
}
