{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shop-reviews",
  "type": "registry:component",
  "title": "Product Reviews",
  "description": "A light product reviews section with an average score, a clickable rating histogram, a recommend ring, filter chips and review cards with verified badges and helpful votes.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "ecommerce",
    "ecommerce",
    "reviews",
    "ratings",
    "histogram",
    "filters",
    "light"
  ],
  "docs": "https://hyperblur.dev/effects/shop-reviews",
  "files": [
    {
      "path": "registry/hyperblur/shop-reviews.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/shop-reviews.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ShopReview {\n  id: string;\n  author: string;\n  location?: string;\n  rating: number;\n  title: string;\n  body: string;\n  date: string;\n  verified?: boolean;\n  variant?: string;\n  helpful?: number;\n  tags?: string[];\n}\n\nexport interface ShopReviewsProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  productName?: string;\n  reviews?: ShopReview[];\n  totalReviews?: number;\n  distribution?: number[];\n  filters?: string[];\n  recommendRate?: number;\n  writeLabel?: string;\n  accent?: string;\n  onWriteReview?: () => void;\n  onVote?: (review: ShopReview, vote: \"up\" | \"down\") => void;\n  onFilterChange?: (filter: string, stars: number | null) => void;\n}\n\nconst defaultReviews: ShopReview[] = [\n  {\n    id: \"r1\",\n    author: \"Hannah K.\",\n    location: \"Portland, OR\",\n    rating: 5,\n    title: \"Warmest jacket I have owned, and it packs tiny\",\n    body: \"Wore it on a 6 day trek in the Dolomites with temps around -4°C. Stayed warm at camp with only a base layer underneath. Fits true to size.\",\n    date: \"Oct 28, 2026\",\n    verified: true,\n    variant: \"Size M · Moss\",\n    helpful: 42,\n    tags: [\"Warmth\", \"Fit\"],\n  },\n  {\n    id: \"r2\",\n    author: \"Marco R.\",\n    location: \"Turin, IT\",\n    rating: 4,\n    title: \"Great quality, sleeves run a bit long\",\n    body: \"Stitching and zippers feel premium. I have long arms and the sleeves still cover my hands, so size down if you are between sizes.\",\n    date: \"Oct 21, 2026\",\n    verified: true,\n    variant: \"Size L · Graphite\",\n    helpful: 18,\n    tags: [\"Fit\", \"Quality\"],\n  },\n  {\n    id: \"r3\",\n    author: \"Yuna P.\",\n    location: \"Seoul, KR\",\n    rating: 5,\n    title: \"Survived a full season of commuting by bike\",\n    body: \"Rain beads right off and the hood fits over my helmet. After four months of daily use it still looks new.\",\n    date: \"Oct 9, 2026\",\n    verified: false,\n    variant: \"Size S · Clay\",\n    helpful: 9,\n    tags: [\"Quality\", \"Rain\"],\n  },\n  {\n    id: \"r4\",\n    author: \"Ethan W.\",\n    location: \"Calgary, CA\",\n    rating: 3,\n    title: \"Warm, but the pockets are shallow\",\n    body: \"Insulation is excellent. My phone nearly slipped out twice while hiking, which is why it loses two stars for me.\",\n    date: \"Sep 30, 2026\",\n    verified: true,\n    variant: \"Size XL · Moss\",\n    helpful: 6,\n    tags: [\"Warmth\"],\n  },\n];\n\nconst css = `\n.hb-yj9 {\n  --hb-yj9-accent: #16a34a;\n  --hb-yj9-star: #f5a524;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  container-type: inline-size;\n  background: #ffffff;\n  color: #111113;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-yj9 *, .hb-yj9 *::before, .hb-yj9 *::after { box-sizing: border-box; }\n.hb-yj9-inner {\n  display: grid;\n  gap: 36px;\n  max-width: 1120px;\n  margin: 0 auto;\n  padding: 72px 20px;\n}\n@container (min-width: 860px) {\n  .hb-yj9-inner { grid-template-columns: 300px minmax(0, 1fr); gap: 56px; align-items: start; padding: 96px 32px; }\n}\n.hb-yj9-eyebrow { margin: 0 0 10px; color: #71717a; font-size: 13px; font-weight: 500; }\n.hb-yj9-title { margin: 0; font-size: clamp(28px, 3.6cqw, 36px); line-height: 1.1; letter-spacing: -.03em; font-weight: 650; }\n.hb-yj9-summary { display: flex; align-items: center; gap: 14px; margin-top: 22px; }\n.hb-yj9-avg { font-size: 54px; line-height: 1; letter-spacing: -.04em; font-weight: 650; font-variant-numeric: tabular-nums; }\n.hb-yj9-stars { display: inline-flex; gap: 2px; color: var(--hb-yj9-star); }\n.hb-yj9-stars svg { width: 16px; height: 16px; }\n.hb-yj9-total { display: block; margin-top: 4px; color: #71717a; font-size: 13px; }\n.hb-yj9-hist { display: grid; gap: 4px; margin-top: 22px; }\n.hb-yj9-hrow {\n  display: grid;\n  grid-template-columns: 42px minmax(0, 1fr) 40px;\n  align-items: center;\n  gap: 10px;\n  width: 100%;\n  padding: 5px 6px;\n  border: 0;\n  border-radius: 8px;\n  background: none;\n  color: #52525b;\n  font: inherit;\n  font-size: 13px;\n  font-variant-numeric: tabular-nums;\n  text-align: left;\n  cursor: pointer;\n  transition: background .2s ease;\n}\n.hb-yj9-hrow:hover { background: #f4f4f5; }\n.hb-yj9-hrow:focus-visible { outline: 2px solid var(--hb-yj9-accent); outline-offset: 1px; }\n.hb-yj9-hrow[aria-pressed=\"true\"] { background: #f4f4f5; color: #111113; font-weight: 600; }\n.hb-yj9-hrow span:last-child { text-align: right; }\n.hb-yj9-track { height: 8px; border-radius: 99px; background: #f0f0f1; overflow: hidden; }\n.hb-yj9-fill {\n  height: 100%;\n  border-radius: inherit;\n  background: var(--hb-yj9-star);\n  transform-origin: left;\n  animation: hb-yj9-grow 1s cubic-bezier(.2, .8, .2, 1) both;\n}\n.hb-yj9-rec {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n  margin-top: 22px;\n  padding: 14px;\n  border: 1px solid #ececee;\n  border-radius: 14px;\n  background: #fafafa;\n  font-size: 13.5px;\n  line-height: 1.4;\n  color: #3f3f46;\n}\n.hb-yj9-ring { flex: none; width: 44px; height: 44px; }\n.hb-yj9-ring circle:last-child { animation: hb-yj9-ring 1.2s cubic-bezier(.2, .8, .2, 1) both; }\n.hb-yj9-write {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  width: 100%;\n  height: 44px;\n  margin-top: 16px;\n  border: 0;\n  border-radius: 999px;\n  background: #111113;\n  color: #fff;\n  font: inherit;\n  font-size: 14px;\n  font-weight: 600;\n  cursor: pointer;\n  transition: background .2s ease, transform .2s ease;\n}\n.hb-yj9-write:hover { background: #000; transform: translateY(-1px); }\n.hb-yj9-write:focus-visible { outline: 2px solid var(--hb-yj9-accent); outline-offset: 3px; }\n.hb-yj9-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }\n.hb-yj9-chips { display: flex; flex-wrap: wrap; gap: 8px; }\n.hb-yj9-chip {\n  height: 34px;\n  padding: 0 14px;\n  border: 1px solid #e4e4e7;\n  border-radius: 999px;\n  background: #fff;\n  color: #3f3f46;\n  font: inherit;\n  font-size: 13px;\n  font-weight: 500;\n  cursor: pointer;\n  transition: all .2s ease;\n}\n.hb-yj9-chip:hover { border-color: #a1a1aa; }\n.hb-yj9-chip:focus-visible { outline: 2px solid var(--hb-yj9-accent); outline-offset: 2px; }\n.hb-yj9-chip[aria-pressed=\"true\"] { background: #111113; border-color: #111113; color: #fff; }\n.hb-yj9-count { color: #71717a; font-size: 13px; }\n.hb-yj9-list { display: grid; gap: 12px; }\n@container (min-width: 1100px) { .hb-yj9-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }\n.hb-yj9-card {\n  display: flex;\n  flex-direction: column;\n  padding: 20px;\n  border: 1px solid #ececee;\n  border-radius: 16px;\n  background: #fff;\n  box-shadow: 0 1px 2px rgba(17, 17, 19, .03);\n  animation: hb-yj9-in .45s cubic-bezier(.2, .8, .2, 1) both;\n  animation-delay: calc(var(--hb-yj9-i) * 60ms);\n}\n.hb-yj9-top { display: flex; align-items: center; gap: 10px; }\n.hb-yj9-av {\n  flex: none;\n  display: grid;\n  place-items: center;\n  width: 36px;\n  height: 36px;\n  border-radius: 50%;\n  color: #fff;\n  font-size: 13px;\n  font-weight: 650;\n}\n.hb-yj9-who { min-width: 0; flex: 1; font-size: 14px; font-weight: 600; }\n.hb-yj9-who span { display: block; color: #71717a; font-size: 12px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-yj9-ver {\n  display: inline-flex;\n  align-items: center;\n  gap: 4px;\n  padding: 3px 8px;\n  border-radius: 999px;\n  background: color-mix(in srgb, var(--hb-yj9-accent) 12%, transparent);\n  color: var(--hb-yj9-accent);\n  font-size: 11.5px;\n  font-weight: 600;\n  white-space: nowrap;\n}\n.hb-yj9-rline { display: flex; align-items: center; gap: 10px; margin-top: 14px; }\n.hb-yj9-rline .hb-yj9-stars svg { width: 14px; height: 14px; }\n.hb-yj9-date { color: #a1a1aa; font-size: 12px; }\n.hb-yj9-card h4 { margin: 8px 0 0; font-size: 15.5px; line-height: 1.35; letter-spacing: -.01em; font-weight: 640; }\n.hb-yj9-card p { margin: 6px 0 0; color: #52525b; font-size: 14px; line-height: 1.55; }\n.hb-yj9-variant { margin-top: 10px; color: #71717a; font-size: 12.5px; }\n.hb-yj9-foot {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  margin-top: auto;\n  padding-top: 14px;\n  color: #71717a;\n  font-size: 12.5px;\n}\n.hb-yj9-foot > span { margin-right: 4px; }\n.hb-yj9-vote {\n  display: inline-flex;\n  align-items: center;\n  gap: 5px;\n  height: 30px;\n  padding: 0 10px;\n  border: 1px solid #e4e4e7;\n  border-radius: 999px;\n  background: #fff;\n  color: #3f3f46;\n  font: inherit;\n  font-size: 12.5px;\n  font-weight: 500;\n  font-variant-numeric: tabular-nums;\n  cursor: pointer;\n  transition: all .2s ease;\n}\n.hb-yj9-vote:hover { border-color: #a1a1aa; }\n.hb-yj9-vote:focus-visible { outline: 2px solid var(--hb-yj9-accent); outline-offset: 2px; }\n.hb-yj9-vote[aria-pressed=\"true\"] { border-color: var(--hb-yj9-accent); background: color-mix(in srgb, var(--hb-yj9-accent) 10%, #fff); color: var(--hb-yj9-accent); }\n.hb-yj9-vote[aria-pressed=\"true\"] svg { animation: hb-yj9-pop .45s cubic-bezier(.3, 1.6, .5, 1); }\n.hb-yj9-empty { padding: 40px 20px; border: 1px dashed #e4e4e7; border-radius: 16px; color: #71717a; font-size: 14px; text-align: center; }\n@keyframes hb-yj9-grow { from { transform: scaleX(0); } }\n@keyframes hb-yj9-in { from { opacity: 0; transform: translateY(10px); } }\n@keyframes hb-yj9-pop { 40% { transform: scale(1.45) rotate(-12deg); } }\n@keyframes hb-yj9-ring { from { stroke-dashoffset: 113.1; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-yj9 *, .hb-yj9 *::before, .hb-yj9 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nconst avatarColors = [\"#0ea5e9\", \"#f97316\", \"#8b5cf6\", \"#14b8a6\", \"#e11d48\", \"#65a30d\"];\n\nfunction Stars({ value }: { value: number }) {\n  return (\n    <span className=\"hb-yj9-stars\" aria-label={`${value} out of 5 stars`}>\n      {[1, 2, 3, 4, 5].map((i) => (\n        <svg key={i} viewBox=\"0 0 20 20\" aria-hidden=\"true\">\n          <path d=\"m10 1.8 2.5 5.1 5.6.8-4 4 1 5.5-5.1-2.6-5 2.6 1-5.5-4.1-4 5.6-.8Z\" fill={i <= Math.round(value) ? \"currentColor\" : \"#e4e4e7\"} />\n        </svg>\n      ))}\n    </span>\n  );\n}\n\nfunction Thumb({ down }: { down?: boolean }) {\n  return (\n    <svg width=\"13\" height=\"13\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\" style={down ? { transform: \"rotate(180deg)\" } : undefined}>\n      <path d=\"M5 7v7H2.5V7H5Zm0 0 3-5c1.2 0 2 .8 2 2v2h3.2c.9 0 1.5.8 1.3 1.6l-1.2 5A1.6 1.6 0 0 1 11.7 14H5\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinejoin=\"round\" />\n    </svg>\n  );\n}\n\nexport function ShopReviews({\n  eyebrow = \"Customer reviews\",\n  title = \"What people say\",\n  productName = \"Alpine Down Jacket\",\n  reviews = defaultReviews,\n  totalReviews = 1284,\n  distribution = [78, 14, 5, 2, 1],\n  filters = [\"All\", \"Verified\", \"Warmth\", \"Fit\", \"Quality\"],\n  recommendRate = 94,\n  writeLabel = \"Write a review\",\n  accent = \"#16a34a\",\n  onWriteReview,\n  onVote,\n  onFilterChange,\n  className,\n  style,\n  ...rest\n}: ShopReviewsProps) {\n  const [filter, setFilter] = React.useState(filters[0] ?? \"All\");\n  const [stars, setStars] = React.useState<number | null>(null);\n  const [votes, setVotes] = React.useState<Record<string, \"up\" | \"down\" | undefined>>({});\n\n  const avg = React.useMemo(() => {\n    const sum = distribution.reduce((a, b) => a + b, 0) || 1;\n    return distribution.reduce((acc, v, i) => acc + v * (5 - i), 0) / sum;\n  }, [distribution]);\n\n  const shown = reviews.filter((r) => {\n    if (stars !== null && Math.round(r.rating) !== stars) return false;\n    if (filter === filters[0]) return true;\n    if (filter === \"Verified\") return !!r.verified;\n    return (r.tags ?? []).includes(filter);\n  });\n\n  const pickFilter = (f: string) => {\n    setFilter(f);\n    onFilterChange?.(f, stars);\n  };\n\n  const pickStars = (s: number) => {\n    const next = stars === s ? null : s;\n    setStars(next);\n    onFilterChange?.(filter, next);\n  };\n\n  const vote = (r: ShopReview, v: \"up\" | \"down\") => {\n    setVotes((m) => ({ ...m, [r.id]: m[r.id] === v ? undefined : v }));\n    onVote?.(r, v);\n  };\n\n  const C = 2 * Math.PI * 18;\n\n  return (\n    <section\n      className={[\"hb-yj9\", className].filter(Boolean).join(\" \")}\n      style={{ \"--hb-yj9-accent\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-shop-reviews\" precedence=\"default\">{css}</style>\n      <div className=\"hb-yj9-inner\">\n        <div>\n          {eyebrow ? <p className=\"hb-yj9-eyebrow\">{eyebrow}</p> : null}\n          <h2 className=\"hb-yj9-title\">{title}</h2>\n          <div className=\"hb-yj9-summary\">\n            <span className=\"hb-yj9-avg\">{avg.toFixed(1)}</span>\n            <span>\n              <Stars value={avg} />\n              <span className=\"hb-yj9-total\">Based on {totalReviews.toLocaleString(\"en-US\")} reviews</span>\n            </span>\n          </div>\n          <div className=\"hb-yj9-hist\" role=\"group\" aria-label=\"Filter by star rating\">\n            {distribution.slice(0, 5).map((v, i) => {\n              const s = 5 - i;\n              return (\n                <button key={s} type=\"button\" className=\"hb-yj9-hrow\" aria-pressed={stars === s} onClick={() => pickStars(s)}>\n                  <span>{s} star</span>\n                  <span className=\"hb-yj9-track\">\n                    <span className=\"hb-yj9-fill\" style={{ display: \"block\", width: `${Math.min(100, Math.max(0, v)).toFixed(1)}%`, animationDelay: `${(i * 0.07).toFixed(2)}s` }} />\n                  </span>\n                  <span>{v}%</span>\n                </button>\n              );\n            })}\n          </div>\n          <div className=\"hb-yj9-rec\">\n            <svg className=\"hb-yj9-ring\" viewBox=\"0 0 44 44\" aria-hidden=\"true\">\n              <circle cx=\"22\" cy=\"22\" r=\"18\" fill=\"none\" stroke=\"#ececee\" strokeWidth=\"5\" />\n              <circle\n                cx=\"22\"\n                cy=\"22\"\n                r=\"18\"\n                fill=\"none\"\n                stroke=\"var(--hb-yj9-accent)\"\n                strokeWidth=\"5\"\n                strokeLinecap=\"round\"\n                strokeDasharray={C.toFixed(1)}\n                strokeDashoffset={(C * (1 - recommendRate / 100)).toFixed(1)}\n                transform=\"rotate(-90 22 22)\"\n              />\n            </svg>\n            <span>\n              <b>{recommendRate}%</b> of buyers would recommend the {productName} to a friend.\n            </span>\n          </div>\n          <button type=\"button\" className=\"hb-yj9-write\" onClick={onWriteReview}>\n            {writeLabel}\n          </button>\n        </div>\n        <div>\n          <div className=\"hb-yj9-bar\">\n            <div className=\"hb-yj9-chips\" role=\"group\" aria-label=\"Filter reviews\">\n              {filters.map((f) => (\n                <button key={f} type=\"button\" className=\"hb-yj9-chip\" aria-pressed={filter === f} onClick={() => pickFilter(f)}>\n                  {f}\n                </button>\n              ))}\n            </div>\n            <span className=\"hb-yj9-count\" aria-live=\"polite\">\n              {stars !== null ? `${stars} star · ` : \"\"}\n              {shown.length} of {reviews.length} shown\n            </span>\n          </div>\n          <div className=\"hb-yj9-list\" key={`${filter}-${stars}`}>\n            {shown.length === 0 ? <div className=\"hb-yj9-empty\">No reviews match these filters yet.</div> : null}\n            {shown.map((r, i) => {\n              const v = votes[r.id];\n              const up = (r.helpful ?? 0) + (v === \"up\" ? 1 : 0);\n              return (\n                <article key={r.id} className=\"hb-yj9-card\" style={{ \"--hb-yj9-i\": i } as React.CSSProperties}>\n                  <div className=\"hb-yj9-top\">\n                    <span className=\"hb-yj9-av\" style={{ background: avatarColors[i % avatarColors.length] }}>\n                      {r.author.charAt(0)}\n                    </span>\n                    <span className=\"hb-yj9-who\">\n                      {r.author}\n                      {r.location ? <span>{r.location}</span> : null}\n                    </span>\n                    {r.verified ? (\n                      <span className=\"hb-yj9-ver\">\n                        <svg width=\"11\" height=\"11\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n                          <path d=\"m3.5 8.3 3 3 6-6.3\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                        </svg>\n                        Verified\n                      </span>\n                    ) : null}\n                  </div>\n                  <div className=\"hb-yj9-rline\">\n                    <Stars value={r.rating} />\n                    <span className=\"hb-yj9-date\">{r.date}</span>\n                  </div>\n                  <h4>{r.title}</h4>\n                  <p>{r.body}</p>\n                  {r.variant ? <div className=\"hb-yj9-variant\">Purchased: {r.variant}</div> : null}\n                  <div className=\"hb-yj9-foot\">\n                    <span>Helpful?</span>\n                    <button type=\"button\" className=\"hb-yj9-vote\" aria-pressed={v === \"up\"} onClick={() => vote(r, \"up\")} aria-label={`Yes, helpful (${up})`}>\n                      <Thumb />\n                      {up}\n                    </button>\n                    <button type=\"button\" className=\"hb-yj9-vote\" aria-pressed={v === \"down\"} onClick={() => vote(r, \"down\")} aria-label=\"Not helpful\">\n                      <Thumb down />\n                      No\n                    </button>\n                  </div>\n                </article>\n              );\n            })}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}