{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rating-review-card",
  "type": "registry:component",
  "title": "Rating Review Card",
  "description": "A public reviews summary: a large average, five stars with fractional fill, the review count, a 5 to 1 distribution that animates in, a Rate us link and an optional top review.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "ordering",
    "reviews",
    "rating",
    "stars",
    "restaurant",
    "social proof",
    "summary"
  ],
  "docs": "https://hyperblur.dev/effects/rating-review-card",
  "files": [
    {
      "path": "registry/hyperblur/rating-review-card.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/rating-review-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface RatingReviewQuote {\n  text: string;\n  author: string;\n  meta?: string;\n  rating?: number;\n}\n\nexport interface RatingReviewLabels {\n  reviews: string;\n  outOf: string;\n  rateUs: string;\n  topReview: string;\n  starsRow: string;\n}\n\nexport interface RatingReviewCardProps extends React.HTMLAttributes<HTMLDivElement> {\n  rating?: number;\n  count?: number;\n  distribution?: number[];\n  source?: string;\n  reviewUrl?: string;\n  quote?: RatingReviewQuote | null;\n  appearance?: \"dark\" | \"light\";\n  accent?: string;\n  starColor?: string;\n  locale?: string;\n  labels?: Partial<RatingReviewLabels>;\n}\n\nconst defaultLabels: RatingReviewLabels = {\n  reviews: \"{n} reviews\",\n  outOf: \"out of 5\",\n  rateUs: \"Rate us\",\n  topReview: \"Top review\",\n  starsRow: \"{s} stars\",\n};\n\nconst defaultQuote: RatingReviewQuote = {\n  text: \"Best smash burger in the neighborhood. Crispy edges, soft bun, and the order was at my door in 25 minutes.\",\n  author: \"Maya R.\",\n  meta: \"2 weeks ago\",\n  rating: 5,\n};\n\nconst starPath = \"M12 2.6l2.82 5.72 6.31.92-4.57 4.45 1.08 6.29L12 17l-5.64 2.98 1.08-6.29L2.87 9.24l6.31-.92z\";\n\nconst css = `\n.hb-od1 {\n  --hb-od1-accent: #2f7bff;\n  --hb-od1-star: #f5b301;\n  --hb-od1-bg: #111111;\n  --hb-od1-surface: #171717;\n  --hb-od1-line: #262626;\n  --hb-od1-track: #232323;\n  --hb-od1-text: #ededed;\n  --hb-od1-muted: #8f8f8f;\n  box-sizing: border-box;\n  container-type: inline-size;\n  width: 100%;\n  color: var(--hb-od1-text);\n  font-family: inherit;\n  font-size: 12px;\n  line-height: 1.4;\n}\n.hb-od1[data-appearance=\"light\"] {\n  --hb-od1-bg: #ffffff;\n  --hb-od1-surface: #f7f6f2;\n  --hb-od1-line: #e7e5df;\n  --hb-od1-track: #efede7;\n  --hb-od1-text: #151515;\n  --hb-od1-muted: #6f6f6f;\n}\n.hb-od1 *, .hb-od1 *::before, .hb-od1 *::after { box-sizing: border-box; }\n.hb-od1-card {\n  display: flex;\n  flex-direction: column;\n  gap: 12px;\n  padding: 14px 16px;\n  border: 1px solid var(--hb-od1-line);\n  border-radius: 18px;\n  background:\n    radial-gradient(90% 70% at 0% 0%, color-mix(in srgb, var(--hb-od1-star) 10%, transparent), transparent 60%),\n    var(--hb-od1-bg);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);\n}\n.hb-od1-top {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 10px;\n}\n.hb-od1-source {\n  display: inline-flex;\n  min-width: 0;\n  align-items: center;\n  gap: 7px;\n  color: var(--hb-od1-muted);\n  font-size: 11.5px;\n  font-weight: 500;\n  white-space: nowrap;\n}\n.hb-od1-source span { overflow: hidden; text-overflow: ellipsis; }\n.hb-od1-source svg { flex: none; color: var(--hb-od1-star); }\n.hb-od1-cta {\n  display: inline-flex;\n  flex: none;\n  align-items: center;\n  gap: 6px;\n  height: 28px;\n  padding: 0 12px;\n  border-radius: 999px;\n  background: var(--hb-od1-text);\n  color: var(--hb-od1-bg);\n  font-size: 11.5px;\n  font-weight: 600;\n  text-decoration: none;\n  transition: transform 0.15s ease, background 0.2s ease;\n}\n.hb-od1-cta:hover { background: color-mix(in srgb, var(--hb-od1-text) 86%, transparent); }\n.hb-od1-cta:active { transform: scale(0.97); }\n.hb-od1-cta:focus-visible { outline: 2px solid var(--hb-od1-accent); outline-offset: 2px; }\n.hb-od1-cta svg { transition: transform 0.2s ease; }\n.hb-od1-cta:hover svg { transform: translateX(2px); }\n.hb-od1-body {\n  display: grid;\n  grid-template-columns: auto minmax(0, 1fr);\n  align-items: center;\n  gap: 18px;\n}\n.hb-od1-score { display: flex; flex-direction: column; gap: 5px; }\n.hb-od1-num {\n  display: flex;\n  align-items: baseline;\n  gap: 5px;\n}\n.hb-od1-big {\n  font-size: 40px;\n  font-weight: 650;\n  letter-spacing: -0.04em;\n  line-height: 0.95;\n  font-variant-numeric: tabular-nums;\n}\n.hb-od1-of { color: var(--hb-od1-muted); font-size: 11px; white-space: nowrap; }\n.hb-od1-stars { display: inline-flex; gap: 2px; }\n.hb-od1-star { position: relative; width: 15px; height: 15px; flex: none; }\n.hb-od1-star svg { position: absolute; inset: 0; width: 15px; height: 15px; display: block; }\n.hb-od1-star-b { fill: color-mix(in srgb, var(--hb-od1-text) 14%, transparent); }\n.hb-od1-star-f {\n  position: absolute;\n  inset: 0 auto 0 0;\n  overflow: hidden;\n  animation: hb-od1-sweep 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;\n  animation-delay: calc(var(--hb-od1-i) * 80ms + 120ms);\n}\n.hb-od1-star-f svg { fill: var(--hb-od1-star); }\n.hb-od1-count { color: var(--hb-od1-muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }\n.hb-od1-bars { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; min-width: 0; }\n.hb-od1-row {\n  display: grid;\n  grid-template-columns: 10px minmax(0, 1fr) 30px;\n  align-items: center;\n  gap: 8px;\n  color: var(--hb-od1-muted);\n  font-size: 11px;\n  font-variant-numeric: tabular-nums;\n}\n.hb-od1-track { height: 6px; border-radius: 999px; background: var(--hb-od1-track); overflow: hidden; }\n.hb-od1-fill {\n  display: block;\n  height: 100%;\n  border-radius: inherit;\n  background: linear-gradient(90deg, color-mix(in srgb, var(--hb-od1-star) 70%, #ff8a00), var(--hb-od1-star));\n  transform-origin: left center;\n  animation: hb-od1-grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;\n  animation-delay: calc(var(--hb-od1-i) * 70ms + 200ms);\n}\n.hb-od1-pct { text-align: right; }\n.hb-od1-quote {\n  position: relative;\n  margin: 0;\n  padding: 12px 14px;\n  border: 1px solid var(--hb-od1-line);\n  border-radius: 14px;\n  background: var(--hb-od1-surface);\n  animation: hb-od1-rise 0.6s 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;\n}\n.hb-od1-qhead {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 8px;\n  margin-bottom: 6px;\n  color: var(--hb-od1-muted);\n  font-size: 10.5px;\n  text-transform: uppercase;\n  letter-spacing: 0.08em;\n}\n.hb-od1-qstars { display: inline-flex; gap: 1px; color: var(--hb-od1-star); }\n.hb-od1-qtext { margin: 0; font-size: 12.5px; line-height: 1.5; font-style: normal; }\n.hb-od1-qby {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  margin-top: 8px;\n  color: var(--hb-od1-muted);\n  font-size: 11px;\n  font-style: normal;\n}\n.hb-od1-qby b { color: var(--hb-od1-text); font-weight: 600; }\n.hb-od1-av {\n  display: inline-grid;\n  place-items: center;\n  width: 22px;\n  height: 22px;\n  border-radius: 50%;\n  background: linear-gradient(135deg, var(--hb-od1-accent), color-mix(in srgb, var(--hb-od1-accent) 40%, #ff7a59));\n  color: #fff;\n  font-size: 10px;\n  font-weight: 700;\n}\n.hb-od1-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n}\n@container (max-width: 290px) {\n  .hb-od1-body { grid-template-columns: 1fr; gap: 12px; }\n}\n@container (min-width: 560px) {\n  .hb-od1-card { padding: 22px 24px; gap: 18px; }\n  .hb-od1-big { font-size: 56px; }\n  .hb-od1-star, .hb-od1-star svg { width: 19px; height: 19px; }\n  .hb-od1-body { gap: 32px; }\n  .hb-od1-bars { gap: 7px; }\n  .hb-od1-track { height: 8px; }\n  .hb-od1-qtext { font-size: 14px; }\n}\n@keyframes hb-od1-grow {\n  from { transform: scaleX(0); }\n  to { transform: scaleX(1); }\n}\n@keyframes hb-od1-sweep {\n  from { clip-path: inset(0 100% 0 0); }\n  to { clip-path: inset(0 0 0 0); }\n}\n@keyframes hb-od1-rise {\n  from { opacity: 0; transform: translateY(6px); }\n  to { opacity: 1; transform: translateY(0); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-od1-fill, .hb-od1-star-f, .hb-od1-quote { animation: none; }\n  .hb-od1-cta, .hb-od1-cta svg { transition: none; }\n}\n`;\n\nfunction Star({ fill, index }: { fill: number; index: number }) {\n  return (\n    <span className=\"hb-od1-star\" aria-hidden=\"true\">\n      <svg viewBox=\"0 0 24 24\" className=\"hb-od1-star-b\">\n        <path d={starPath} />\n      </svg>\n      <span className=\"hb-od1-star-f\" style={{ width: `${(fill * 100).toFixed(1)}%`, \"--hb-od1-i\": index } as React.CSSProperties}>\n        <svg viewBox=\"0 0 24 24\">\n          <path d={starPath} />\n        </svg>\n      </span>\n    </span>\n  );\n}\n\nexport function RatingReviewCard({\n  rating,\n  count,\n  distribution = [968, 214, 58, 22, 22],\n  source = \"Customer reviews\",\n  reviewUrl = \"https://cornerkitchen.example/reviews\",\n  quote = defaultQuote,\n  appearance = \"dark\",\n  accent = \"#2f7bff\",\n  starColor = \"#f5b301\",\n  locale = \"en-US\",\n  labels,\n  className = \"\",\n  style,\n  ...rest\n}: RatingReviewCardProps) {\n  const l = { ...defaultLabels, ...labels };\n  const rows = [0, 1, 2, 3, 4].map((i) => Math.max(0, distribution[i] ?? 0));\n  const sum = rows.reduce((a, b) => a + b, 0);\n  const average = sum > 0 ? rows.reduce((a, n, i) => a + n * (5 - i), 0) / sum : 0;\n  const value = Math.min(5, Math.max(0, rating ?? average));\n  const shown = new Intl.NumberFormat(locale, { minimumFractionDigits: 1, maximumFractionDigits: 1 }).format(value);\n  const countText = l.reviews.replace(\"{n}\", new Intl.NumberFormat(locale).format(count ?? sum));\n\n  return (\n    <div\n      className={`hb-od1 ${className}`}\n      data-appearance={appearance}\n      style={{ \"--hb-od1-accent\": accent, \"--hb-od1-star\": starColor, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-rating-review-card\" precedence=\"default\">{css}</style>\n      <section className=\"hb-od1-card\" aria-label={source}>\n        <div className=\"hb-od1-top\">\n          <span className=\"hb-od1-source\">\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n              <path d={starPath} />\n            </svg>\n            <span>{source}</span>\n          </span>\n          {reviewUrl ? (\n            <a className=\"hb-od1-cta\" href={reviewUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n              {l.rateUs}\n              <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                <path d=\"M5 12h13M13 6l6 6-6 6\" />\n              </svg>\n            </a>\n          ) : null}\n        </div>\n        <div className=\"hb-od1-body\">\n          <div className=\"hb-od1-score\">\n            <div className=\"hb-od1-num\">\n              <span className=\"hb-od1-big\">{shown}</span>\n              <span className=\"hb-od1-of\">{l.outOf}</span>\n            </div>\n            <span className=\"hb-od1-stars\" role=\"img\" aria-label={`${shown} ${l.outOf}`}>\n              {[0, 1, 2, 3, 4].map((i) => (\n                <Star key={i} index={i} fill={Math.min(1, Math.max(0, value - i))} />\n              ))}\n            </span>\n            <span className=\"hb-od1-count\">{countText}</span>\n          </div>\n          <ul className=\"hb-od1-bars\">\n            {rows.map((n, i) => {\n              const pct = sum > 0 ? (n / sum) * 100 : 0;\n              const stars = 5 - i;\n              return (\n                <li key={stars} className=\"hb-od1-row\">\n                  <span className=\"hb-od1-sr\">{`${l.starsRow.replace(\"{s}\", String(stars))}: ${Math.round(pct)}%`}</span>\n                  <span aria-hidden=\"true\">{stars}</span>\n                  <span className=\"hb-od1-track\" aria-hidden=\"true\">\n                    <span className=\"hb-od1-fill\" style={{ width: `${pct.toFixed(2)}%`, \"--hb-od1-i\": i } as React.CSSProperties} />\n                  </span>\n                  <span className=\"hb-od1-pct\" aria-hidden=\"true\">{`${Math.round(pct)}%`}</span>\n                </li>\n              );\n            })}\n          </ul>\n        </div>\n        {quote ? (\n          <figure className=\"hb-od1-quote\">\n            <div className=\"hb-od1-qhead\">\n              <span>{l.topReview}</span>\n              {quote.rating ? (\n                <span className=\"hb-od1-qstars\" role=\"img\" aria-label={`${quote.rating} ${l.outOf}`}>\n                  {Array.from({ length: Math.round(Math.min(5, Math.max(0, quote.rating))) }, (_, i) => (\n                    <svg key={i} width=\"11\" height=\"11\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n                      <path d={starPath} />\n                    </svg>\n                  ))}\n                </span>\n              ) : null}\n            </div>\n            <blockquote className=\"hb-od1-qtext\">{quote.text}</blockquote>\n            <figcaption className=\"hb-od1-qby\">\n              <span className=\"hb-od1-av\" aria-hidden=\"true\">{quote.author.trim().charAt(0).toUpperCase()}</span>\n              <b>{quote.author}</b>\n              {quote.meta ? <span>{quote.meta}</span> : null}\n            </figcaption>\n          </figure>\n        ) : null}\n      </section>\n    </div>\n  );\n}\n"
    }
  ]
}