{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ecommerce-12",
  "type": "registry:block",
  "description": "Reviews section with rating distribution bars that filter a list of verified reviews with helpful votes.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "button"
  ],
  "files": [
    {
      "path": "registry/designali/blocks/ecommerce/ecommerce-12.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport {\n  BadgeCheck,\n  Star,\n  ThumbsUp,\n} from \"@designali/icons\"\n\nimport { Button } from \"@workspace/ui/components/button\"\nimport { cn } from \"@workspace/ui/lib/utils\"\nimport { CounterNumber } from \"@/registry/designali/ui/counter-number\"\n\nconst distribution = [\n  { stars: 5, count: 812 },\n  { stars: 4, count: 241 },\n  { stars: 3, count: 64 },\n  { stars: 2, count: 21 },\n  { stars: 1, count: 18 },\n]\n\nconst reviews = [\n  { name: \"Tomasz W.\", initials: \"TW\", rating: 5, date: \"2 Nov 2026\", title: \"Launched my studio site in a weekend\", body: \"The Next.js code is clean and the Figma file matches it block for block. Swapped the copy, changed the primary color and shipped it on Vercel.\", fit: \"License: Pro\", helpful: 48 },\n  { name: \"Aisha R.\", initials: \"AR\", rating: 4, date: \"28 Oct 2026\", title: \"Great build, wish it had one more case study layout\", body: \"Typography and spacing feel excellent and dark mode just works. I wanted one more case study page, which is the only reason for four stars.\", fit: \"License: Solo\", helpful: 21 },\n  { name: \"Lena K.\", initials: \"LK\", rating: 5, date: \"19 Oct 2026\", title: \"Replaced my old agency site after eight years\", body: \"Used it with Designali blocks and @designali/icons. Every section is responsive and the components stay consistent.\", fit: \"License: Studio\", helpful: 17 },\n  { name: \"Marcus O.\", initials: \"MO\", rating: 3, date: \"4 Oct 2026\", title: \"Solid, but more than I needed\", body: \"It is a full design system. If you want a one-page site this is a lot, but for a growing studio I have no complaints.\", fit: \"License: Pro\", helpful: 9 },\n]\n\nfunction Stars({ value, className }: { value: number; className?: string }) {\n  return (\n    <span className={cn(\"flex gap-0.5\", className)} aria-label={`${value} out of 5 stars`}>\n      {[1, 2, 3, 4, 5].map((n) => (\n        <Star\n          key={n}\n          className={cn(\"size-3.5\", n <= value ? \"fill-primary text-primary\" : \"text-muted-foreground/40\")}\n        />\n      ))}\n    </span>\n  )\n}\n\nexport default function Ecommerce12() {\n  const [filter, setFilter] = useState<number | null>(null)\n  const [helpful, setHelpful] = useState<string[]>([])\n  const total = distribution.reduce((s, d) => s + d.count, 0)\n  const average = distribution.reduce((s, d) => s + d.stars * d.count, 0) / total\n  const visible = filter ? reviews.filter((r) => r.rating === filter) : reviews\n\n  return (\n    <section className=\"w-full bg-background py-16 text-foreground md:py-24\">\n      <div className=\"mx-auto grid max-w-6xl gap-12 px-6 lg:grid-cols-[320px_1fr]\">\n        <div>\n          <h2 className=\"text-2xl font-medium tracking-tight\">Customer reviews</h2>\n          <div className=\"mt-6 flex items-end gap-3\">\n            <CounterNumber value={average} decimalPlaces={1} size=\"xl\" className=\"text-6xl font-semibold tracking-tight\" />\n            <div className=\"pb-2\">\n              <Stars value={Math.round(average)} />\n              <p className=\"mt-1 text-xs text-muted-foreground\">\n                <CounterNumber value={total} size=\"sm\" color=\"secondary\" className=\"text-xs tracking-normal\" /> reviews\n              </p>\n            </div>\n          </div>\n\n          <ul className=\"mt-6 space-y-1\">\n            {distribution.map((d) => {\n              const pct = Math.round((d.count / total) * 100)\n              const isActive = filter === d.stars\n              return (\n                <li key={d.stars}>\n                  <button\n                    type=\"button\"\n                    onClick={() => setFilter(isActive ? null : d.stars)}\n                    aria-pressed={isActive}\n                    className={cn(\n                      \"flex w-full items-center gap-3 px-2 py-1.5 text-sm transition-colors\",\n                      isActive ? \"bg-muted\" : \"hover:bg-muted/60\"\n                    )}\n                  >\n                    <span className=\"w-10 text-left text-muted-foreground\">{d.stars} star</span>\n                    <span className=\"h-2 flex-1 bg-muted\">\n                      <span className=\"block h-full bg-primary\" style={{ width: `${pct}%` }} />\n                    </span>\n                    <span className=\"w-10 text-right text-xs text-muted-foreground tabular-nums\">{pct}%</span>\n                  </button>\n                </li>\n              )\n            })}\n          </ul>\n\n          <div className=\"mt-8 border border-border p-5\">\n            <p className=\"text-sm font-medium\">Own the Design Agency Template?</p>\n            <p className=\"mt-1 text-xs text-muted-foreground\">Share how it has held up for you.</p>\n            <Button variant=\"outline\" className=\"mt-4 w-full\">\n              Write a review\n            </Button>\n          </div>\n        </div>\n\n        <div>\n          <div className=\"flex items-center justify-between border-b border-border pb-4 text-sm\">\n            <span className=\"text-muted-foreground\">\n              {filter ? `Showing ${filter}-star reviews` : \"Most helpful first\"}\n            </span>\n            {filter && (\n              <button type=\"button\" onClick={() => setFilter(null)} className=\"underline underline-offset-4\">\n                Show all\n              </button>\n            )}\n          </div>\n          <ul className=\"divide-y divide-border\">\n            {visible.length === 0 && (\n              <li className=\"py-12 text-center text-sm text-muted-foreground\">No reviews with this rating yet.</li>\n            )}\n            {visible.map((r) => {\n              const voted = helpful.includes(r.name)\n              return (\n                <li key={r.name} className=\"py-6\">\n                  <div className=\"flex items-center gap-3\">\n                    <span className=\"flex size-9 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium\">\n                      {r.initials}\n                    </span>\n                    <div className=\"min-w-0 flex-1\">\n                      <p className=\"flex items-center gap-1.5 text-sm font-medium\">\n                        {r.name}\n                        <BadgeCheck className=\"size-3.5 text-primary dark:text-primary\" aria-label=\"Verified buyer\" />\n                      </p>\n                      <p className=\"text-xs text-muted-foreground\">\n                        {r.date} · {r.fit}\n                      </p>\n                    </div>\n                    <Stars value={r.rating} className=\"shrink-0\" />\n                  </div>\n                  <h3 className=\"mt-4 font-medium\">{r.title}</h3>\n                  <p className=\"mt-2 text-sm leading-6 text-muted-foreground\">{r.body}</p>\n                  <button\n                    type=\"button\"\n                    onClick={() =>\n                      setHelpful((h) => (h.includes(r.name) ? h.filter((n) => n !== r.name) : [...h, r.name]))\n                    }\n                    aria-pressed={voted}\n                    className={cn(\n                      \"mt-4 flex items-center gap-2 border px-3 py-1.5 text-xs transition-colors\",\n                      voted ? \"border-foreground\" : \"border-border text-muted-foreground hover:text-foreground\"\n                    )}\n                  >\n                    <ThumbsUp className=\"size-3.5\" />\n                    Helpful ({r.helpful + (voted ? 1 : 0)})\n                  </button>\n                </li>\n              )\n            })}\n          </ul>\n        </div>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "iframeHeight": "1000px"
  },
  "categories": [
    "ecommerce"
  ]
}