{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "testimonials-rating",
  "type": "registry:block",
  "title": "Testimonials, rating",
  "description": "A review-site look: a big average score with stars and the review count on the left, two to four star-rated reviews with a headline, text, name and date on the right. Stars are decorative; the rating is read out as \"5 out of 5 stars\". The score card is drawn only when score holds the business's real rating; with no real rating, leave score and basis empty and only the reviews show. With a real rating and no review texts (reviews empty) it is a slim strip: stars, score and count on one line beside the title, and a link to the reviews.",
  "categories": [
    "testimonials"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "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/text-link.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/testimonials-rating/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/testimonials-rating/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, req, t } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: req(120),\n  /** The business's real average from a named source (its Google rating). Empty: the summary card is not drawn. Never invented. */\n  score: t(8),\n  /** Stars filled in the summary, as a whole number. */\n  scoreStars: z.enum(['1', '2', '3', '4', '5']).optional(),\n  outOf: req(30),\n  basis: t(80),\n  reviews: z.array(z.object({\n    stars: z.enum(['1', '2', '3', '4', '5']),\n    headline: req(80),\n    text: t(280),\n    name: req(60),\n    when: t(40),\n  })).max(4),\n  /** Where the reviews live (their Google or Trustpilot page). Empty: no link. */\n  link: link.optional(),\n});\n\nexport const spec = defineSpec({\n  type: 'testimonials-rating',\n  aliases: ['testimonials/rating'],\n  name: 'Testimonials, rating',\n  category: 'testimonials',\n  role: 'body',\n  description: 'A review-site look: a big average score with stars and the review count on the left, two to four star-rated reviews with a headline, text, name and date on the right. Stars are decorative; the rating is read out as \"5 out of 5 stars\". The score card is drawn only when score holds the business\\'s real rating; with no real rating, leave score and basis empty and only the reviews show. With a real rating and no review texts (reviews empty) it is a slim strip: stars, score and count on one line beside the title, and a link to the reviews.',\n  schema,\n  defaults: {\n    eyebrow: 'Section name',\n    title: 'Say what the average rating is',\n    score: '0.0',\n    scoreStars: '5',\n    outOf: 'out of 5 stars',\n    basis: 'Say where the rating comes from',\n    link: { label: '', href: '' },\n    reviews: [\n      { stars: '5', headline: 'Give the review a headline', text: 'Say in a sentence or two what the reviewer liked, with one concrete detail.', name: 'Name a person', when: 'Say when, as a month' },\n      { stars: '5', headline: 'Give the review a headline', text: 'Say in a sentence or two what the reviewer liked, with one concrete detail.', name: 'Name a person', when: 'Say when, as a month' },\n      { stars: '4', headline: 'Give the review a headline', text: 'Say in a sentence or two what the reviewer liked, with one concrete detail.', name: 'Name a person', when: 'Say when, as a month' },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/testimonials-rating/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/testimonials-rating/index.tsx",
      "content": "import { useId } from 'react';\nimport { Star } from 'lucide-react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { ArrowUpRight } from 'lucide-react';\nimport { safeHref } from '../../ui/button';\nimport { linkClass } from '../../ui/text-link';\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\nfunction Stars({ n, className }: { n: number; className?: string }) {\n  return (\n    <span aria-hidden className={cn('inline-flex gap-0.5', className)}>\n      {[1, 2, 3, 4, 5].map((i) => (\n        <Star key={i} strokeWidth={1.75} className={cn('size-5', i <= n ? 'fill-kh-accent text-kh-accent' : 'text-kh-line-strong')} />\n      ))}\n    </span>\n  );\n}\n\nfunction TestimonialsRating({ props }: BlockProps<Props>) {\n  const id = useId();\n  const editing = useEditing();\n  // The score card is proof only when the number is the business's own rating: drawn when a score is given (or while editing).\n  const showScore = Boolean(props.score) || editing;\n  const link = (props.link?.label || editing) && (\n    <a href={safeHref(props.link?.href ?? '')} className={cn(linkClass(), 'inline-flex min-h-11 items-center gap-1 text-kh-small font-medium no-underline')}>\n      <Text path={['link', 'label']} value={props.link?.label ?? ''} as=\"span\" placeholder=\"Read the reviews\" />\n      <ArrowUpRight aria-hidden className=\"size-4\" />\n    </a>\n  );\n  if (props.reviews.length === 0) {\n    // No review texts on their page, only the rating ('4.7, 528 Google reviews'): a slim strip. No rating either: nothing real to show.\n    if (!showScore) return null;\n    return (\n      <Section labelledBy={id} className=\"py-8\">\n        <Container>\n          <div className=\"flex flex-col gap-4 border-y border-kh-line py-6 @3xl:flex-row @3xl:items-center @3xl:justify-between @3xl:gap-10\">\n            <div id={id} className=\"min-w-0\">\n              <Text path={['title']} value={props.title} as=\"h2\" className=\"text-kh-heading font-semibold\" />\n            </div>\n            <div className=\"flex flex-wrap items-center gap-x-6 gap-y-2\">\n              {/* Narrow: the count gets its own line (no separator left at a line start); wide: one row with a separator. */}\n              <p className=\"flex flex-col gap-1 @md:flex-row @md:items-center @md:gap-3\">\n                <span className=\"flex items-center gap-3\">\n                  {props.scoreStars && <Stars n={Number(props.scoreStars)} />}\n                  <Text path={['score']} value={props.score} as=\"span\" className=\"text-kh-heading font-semibold tabular-nums\" />\n                  <Text path={['outOf']} value={props.outOf} as=\"span\" className=\"text-kh-small text-kh-muted\" />\n                </span>\n                <Opt path={['basis']} value={props.basis} as=\"span\" className=\"text-kh-small text-kh-muted @md:before:mr-3 @md:before:content-['·']\" placeholder=\"Based on\" />\n              </p>\n              {link}\n            </div>\n          </div>\n        </Container>\n      </Section>\n    );\n  }\n  return (\n    <Section labelledBy={id}>\n      <Container className=\"grid gap-12 @4xl:grid-cols-[1fr_1.6fr] @4xl:gap-20\">\n        <div>\n          <Eyebrow path={['eyebrow']} value={props.eyebrow} />\n          <div id={id}>\n            <Text path={['title']} value={props.title} as=\"h2\" className=\"text-kh-title font-semibold\" />\n          </div>\n          {showScore && <div className=\"mt-10 rounded-kh-xl border border-kh-line bg-kh-surface p-8\">\n            <p className=\"flex items-end gap-3\">\n              <Text path={['score']} value={props.score} as=\"span\" className=\"max-w-full text-kh-display font-semibold leading-none tabular-nums [overflow-wrap:anywhere]\" />\n              <Text path={['outOf']} value={props.outOf} as=\"span\" className=\"pb-1 text-kh-small text-kh-muted\" />\n            </p>\n            {props.scoreStars && <Stars n={Number(props.scoreStars)} className=\"mt-4\" />}\n            <Opt path={['basis']} value={props.basis} className=\"mt-3 text-kh-small text-kh-muted\" placeholder=\"Based on\" />\n          </div>}\n          {link && <p className=\"mt-4\">{link}</p>}\n        </div>\n        <ul className=\"divide-y divide-kh-line border-y border-kh-line\">\n          {props.reviews.map((r, i) => (\n            <li key={i}>\n              <article className=\"py-7\">\n                <p className=\"flex items-center gap-3\">\n                  <Stars n={Number(r.stars)} />\n                  <span className=\"sr-only\">{r.stars} {props.outOf}</span>\n                </p>\n                <Text path={['reviews', i, 'headline']} value={r.headline} as=\"h3\" className=\"mt-3 text-kh-heading font-semibold\" />\n                <Opt path={['reviews', i, 'text']} value={r.text} multiline className=\"mt-2 text-kh-body text-kh-muted\" placeholder=\"Review\" />\n                <p className=\"mt-4 text-kh-small\">\n                  <Text path={['reviews', i, 'name']} value={r.name} as=\"span\" className=\"font-medium\" />\n                  <Opt path={['reviews', i, 'when']} value={r.when} as=\"span\" className=\"text-kh-muted before:mx-2 before:content-['·']\" placeholder=\"When\" />\n                </p>\n              </article>\n            </li>\n          ))}\n        </ul>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(TestimonialsRating);\n"
    }
  ]
}
