{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"review-cards-summary","type":"registry:component","title":"Review cards · Rating summary","description":"Average that counts up over a star histogram whose bars grow in and filter the list.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/review-cards/summary.tsx","type":"registry:component","target":"components/examples/review-cards/summary.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion, useSpring, useTransform } from \"motion/react\";\nimport { Star, X } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface RatingSummaryCardProps {\n  /** Review counts per star, index 0 = 5 stars … index 4 = 1 star. */\n  counts?: [number, number, number, number, number];\n  title?: string;\n  /** Short line under the title, e.g. the product name. */\n  subtitle?: string;\n  /** Initially selected star filter (1–5), or null for all. */\n  defaultFilter?: number | null;\n  onFilterChange?: (stars: number | null) => void;\n  onWriteReview?: () => void;\n  className?: string;\n}\n\nconst focus = \"outline-none focus-visible:shadow-[var(--focus-ring)]\";\n\nfunction Stars({ value, className }: { value: number; className?: string }) {\n  return (\n    <span className={cn(\"relative inline-flex\", className)} aria-hidden>\n      <span className=\"flex gap-0.5 text-ink-subtle/40\">\n        {Array.from({ length: 5 }, (_, i) => (\n          <Star key={i} className=\"size-4\" fill=\"currentColor\" strokeWidth={0} />\n        ))}\n      </span>\n      <span className=\"absolute inset-0 flex gap-0.5 overflow-hidden text-volt-ink\" style={{ width: `${(value / 5) * 100}%` }}>\n        {Array.from({ length: 5 }, (_, i) => (\n          <Star key={i} className=\"size-4 shrink-0\" fill=\"currentColor\" strokeWidth={0} />\n        ))}\n      </span>\n    </span>\n  );\n}\n\n/** Rating summary: the average counts up, the star histogram grows in, and every bar filters the review list below it. */\nexport function RatingSummaryCard({\n  counts = [1284, 412, 96, 31, 18],\n  title = \"Customer reviews\",\n  subtitle = \"Halden Desk Lamp · Oak\",\n  defaultFilter = null,\n  onFilterChange,\n  onWriteReview,\n  className,\n}: RatingSummaryCardProps) {\n  const reduce = useReducedMotion() ?? false;\n  const [filter, setFilter] = React.useState<number | null>(defaultFilter);\n  const total = counts.reduce((a, b) => a + b, 0);\n  const average = total ? counts.reduce((sum, c, i) => sum + c * (5 - i), 0) / total : 0;\n  const max = Math.max(...counts, 1);\n  const recommend = total ? Math.round(((counts[0] + counts[1]) / total) * 100) : 0;\n\n  const mv = useSpring(reduce ? average : 0, { stiffness: 60, damping: 18 });\n  const shown = useTransform(mv, (v) => v.toFixed(1));\n  React.useEffect(() => {\n    if (reduce) mv.jump(average);\n    else mv.set(average);\n  }, [average, reduce, mv]);\n\n  function choose(next: number | null) {\n    setFilter(next);\n    onFilterChange?.(next);\n  }\n\n  return (\n    <section aria-label={title} className={cn(\"w-full max-w-[380px] rounded-xl border border-border bg-surface-raised p-5 shadow-sm\", className)}>\n      <header className=\"flex items-start justify-between gap-3\">\n        <div>\n          <h3 className=\"text-[15px] font-semibold text-ink\">{title}</h3>\n          <p className=\"text-xs text-ink-subtle\">{subtitle}</p>\n        </div>\n        <span className=\"rounded-full bg-volt-soft px-2.5 py-1 text-[11px] font-medium text-volt-ink\">{recommend}% recommend</span>\n      </header>\n\n      <div className=\"mt-4 flex items-end gap-3\">\n        <p className=\"font-display text-[44px] font-semibold leading-none tracking-[-1.5px] text-ink tabular-nums\">\n          <motion.span aria-hidden>{shown}</motion.span>\n          <span className=\"sr-only\">{average.toFixed(1)} out of 5</span>\n        </p>\n        <div className=\"pb-1\">\n          <Stars value={average} />\n          <p className=\"mt-1 text-xs text-ink-muted\">Based on {total.toLocaleString(\"en-US\")} reviews</p>\n        </div>\n      </div>\n\n      <div role=\"group\" aria-label=\"Filter reviews by rating\" className=\"mt-5 space-y-1\">\n        {counts.map((count, i) => {\n          const stars = 5 - i;\n          const on = filter === stars;\n          const dim = filter !== null && !on;\n          const pct = total ? Math.round((count / total) * 100) : 0;\n          return (\n            <motion.button\n              key={stars}\n              type=\"button\"\n              aria-pressed={on}\n              aria-label={`${stars} star, ${count} reviews, ${pct}%`}\n              whileTap={reduce ? undefined : { scale: 0.98 }}\n              onClick={() => choose(on ? null : stars)}\n              className={cn(\"group flex w-full items-center gap-3 rounded-sm px-2 py-1.5 transition-colors hover:bg-surface-hover\", on && \"bg-surface-hover\", focus)}\n            >\n              <span className={cn(\"flex w-7 items-center gap-0.5 text-xs font-medium tabular-nums transition-opacity\", dim ? \"text-ink-subtle\" : \"text-ink\")}>\n                {stars}\n                <Star aria-hidden className=\"size-3\" fill=\"currentColor\" strokeWidth={0} />\n              </span>\n              <span className=\"relative h-2 flex-1 overflow-hidden rounded-full bg-surface-sunken\">\n                <motion.span\n                  className={cn(\"absolute inset-y-0 left-0 origin-left rounded-full transition-colors\", on ? \"bg-volt\" : dim ? \"bg-ink-subtle/35\" : \"bg-ink/75\")}\n                  style={{ width: `${(count / max) * 100}%` }}\n                  initial={reduce ? false : { scaleX: 0 }}\n                  animate={{ scaleX: 1 }}\n                  transition={{ type: \"spring\", stiffness: 120, damping: 20, delay: reduce ? 0 : 0.1 + i * 0.07 }}\n                />\n              </span>\n              <span className={cn(\"w-10 text-right font-mono text-[11px] tabular-nums\", dim ? \"text-ink-subtle\" : \"text-ink-muted\")}>{pct}%</span>\n            </motion.button>\n          );\n        })}\n      </div>\n\n      <div className=\"mt-4 flex min-h-9 items-center justify-between gap-3 border-t border-border pt-4\">\n        <AnimatePresence mode=\"popLayout\" initial={false}>\n          {filter ? (\n            <motion.button\n              key=\"chip\"\n              type=\"button\"\n              aria-label={`Clear ${filter}-star filter`}\n              onClick={() => choose(null)}\n              initial={{ opacity: 0, filter: \"blur(8px)\" }}\n              animate={{ opacity: 1, filter: \"blur(0px)\" }}\n              exit={{ opacity: 0, filter: \"blur(8px)\" }}\n              className={cn(\"inline-flex h-8 items-center gap-1.5 rounded-full border border-border-strong px-3 text-xs text-ink\", focus)}\n            >\n              {filter}-star · {counts[5 - filter].toLocaleString(\"en-US\")}\n              <X aria-hidden className=\"size-3.5 text-ink-muted\" />\n            </motion.button>\n          ) : (\n            <motion.p\n              key=\"all\"\n              initial={{ opacity: 0, filter: \"blur(8px)\" }}\n              animate={{ opacity: 1, filter: \"blur(0px)\" }}\n              exit={{ opacity: 0, filter: \"blur(8px)\" }}\n              className=\"text-xs text-ink-subtle\"\n            >\n              Showing all ratings\n            </motion.p>\n          )}\n        </AnimatePresence>\n        <motion.button\n          type=\"button\"\n          whileTap={reduce ? undefined : { scale: 0.96 }}\n          onClick={onWriteReview}\n          className={cn(\"h-9 shrink-0 rounded-full bg-volt px-4 text-[13px] font-semibold text-on-volt\", focus)}\n        >\n          Write a review\n        </motion.button>\n      </div>\n      <p aria-live=\"polite\" className=\"sr-only\">\n        {filter ? `Showing ${filter}-star reviews` : \"Showing all reviews\"}\n      </p>\n    </section>\n  );\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["examples","reviews","rating","stars","testimonial","ecommerce","feedback","histogram","card"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/review-cards#summary"}}