{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "review-card",
  "type": "registry:component",
  "title": "Review Card",
  "description": "A customer review with avatar, half-star rating, a Read more clamp, a verified badge and a helpful vote.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "social",
    "review",
    "rating",
    "testimonial",
    "card",
    "feedback",
    "reviews"
  ],
  "docs": "https://hyperblur.dev/effects/review-card",
  "files": [
    {
      "path": "registry/hyperblur/review-card.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/review-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ReviewCardProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  rating?: number;\n  name?: string;\n  date?: string;\n  title?: string;\n  text?: string;\n  verified?: boolean;\n  helpful?: number;\n  avatar?: string;\n  lines?: number;\n}\n\nconst css = `\n.hb-rv {\n  position: relative;\n  box-sizing: border-box;\n  display: flex;\n  flex-direction: column;\n  gap: 10px;\n  width: 100%;\n  padding: 16px;\n  border: 1px solid #262626;\n  border-radius: 14px;\n  background: #111111;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 14px;\n  line-height: 1.5;\n  text-align: left;\n}\n.hb-rv *, .hb-rv *::before, .hb-rv *::after { box-sizing: border-box; }\n.hb-rv-top {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  min-width: 0;\n}\n.hb-rv-av {\n  position: relative;\n  display: grid;\n  flex: none;\n  place-items: center;\n  width: 32px;\n  height: 32px;\n  overflow: hidden;\n  border-radius: 50%;\n  background: var(--hb-bg);\n  color: var(--hb-fg);\n  font-size: 12px;\n  font-weight: 600;\n  letter-spacing: 0.02em;\n}\n.hb-rv-img {\n  position: absolute;\n  inset: 0;\n  background-position: center;\n  background-size: cover;\n}\n.hb-rv-who {\n  display: flex;\n  flex: 1;\n  align-items: center;\n  gap: 8px;\n  min-width: 0;\n}\n.hb-rv-name {\n  overflow: hidden;\n  font-weight: 600;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n}\n.hb-rv-ok {\n  display: inline-flex;\n  flex: none;\n  align-items: center;\n  gap: 4px;\n  color: #4ade80;\n  font-size: 11px;\n  font-weight: 500;\n  white-space: nowrap;\n}\n.hb-rv-ok svg {\n  width: 12px;\n  height: 12px;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 2.4;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n.hb-rv-date {\n  flex: none;\n  color: #8f8f8f;\n  font-size: 12px;\n  white-space: nowrap;\n}\n.hb-rv-rate {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  min-width: 0;\n}\n.hb-rv-stars {\n  display: inline-flex;\n  flex: none;\n}\n.hb-rv-star {\n  position: relative;\n  flex: none;\n  width: 14px;\n  height: 14px;\n}\n.hb-rv-star svg {\n  position: absolute;\n  inset: 0;\n  width: 14px;\n  height: 14px;\n  display: block;\n}\n.hb-rv-star-b { fill: rgba(255, 255, 255, 0.14); }\n.hb-rv-star-f {\n  position: absolute;\n  top: 0;\n  left: 0;\n  height: 100%;\n  overflow: hidden;\n}\n.hb-rv-star-f svg { fill: #f5b301; }\n.hb-rv-title {\n  overflow: hidden;\n  font-weight: 600;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n}\n.hb-rv-text {\n  margin: 0;\n  color: #bdbdbd;\n  font-size: 13px;\n  line-height: 1.5;\n  overflow-wrap: anywhere;\n}\n.hb-rv-text[data-open=\"false\"] {\n  display: -webkit-box;\n  overflow: hidden;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: var(--hb-l);\n  line-clamp: var(--hb-l);\n}\n.hb-rv-foot {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 8px;\n  min-height: 28px;\n}\n.hb-rv-btn {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  margin: 0;\n  padding: 5px 10px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  background: #171717;\n  color: #8f8f8f;\n  font: inherit;\n  font-size: 12px;\n  font-weight: 500;\n  line-height: 1.2;\n  cursor: pointer;\n  touch-action: manipulation;\n  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;\n}\n.hb-rv-btn:hover { color: #ededed; border-color: #3a3a3a; }\n.hb-rv-btn:focus-visible { outline: 2px solid #ededed; outline-offset: 2px; }\n.hb-rv-btn[aria-pressed=\"true\"] {\n  color: #ededed;\n  border-color: #4a4a4a;\n  background: #1f1f1f;\n}\n.hb-rv-btn svg {\n  width: 14px;\n  height: 14px;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 1.8;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n.hb-rv-btn[aria-pressed=\"true\"] svg { fill: currentColor; fill-opacity: 0.2; }\n.hb-rv-more {\n  margin: 0;\n  padding: 4px 2px;\n  border: 0;\n  background: none;\n  color: #8f8f8f;\n  font: inherit;\n  font-size: 12px;\n  font-weight: 500;\n  text-decoration: underline;\n  text-underline-offset: 3px;\n  text-decoration-color: #3a3a3a;\n  cursor: pointer;\n}\n.hb-rv-more:hover { color: #ededed; }\n.hb-rv-more:focus-visible { outline: 2px solid #ededed; outline-offset: 2px; border-radius: 4px; }\n.hb-rv-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`;\n\nconst starPath =\n  \"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z\";\n\nfunction hash(input: string) {\n  let h = 0;\n  for (let i = 0; i < input.length; i++) h = (Math.imul(h, 31) + input.charCodeAt(i)) >>> 0;\n  return h;\n}\n\nfunction initials(name: string) {\n  const words = name.trim().split(/\\s+/).filter(Boolean);\n  if (words.length === 0) return \"?\";\n  const first = words[0][0] ?? \"\";\n  const last = words.length > 1 ? (words[words.length - 1][0] ?? \"\") : \"\";\n  return (first + last).toUpperCase();\n}\n\nexport function ReviewCard({\n  rating = 5,\n  name = \"Anonymous\",\n  date = \"\",\n  title = \"\",\n  text = \"\",\n  verified = false,\n  helpful = 0,\n  avatar,\n  lines = 3,\n  className = \"\",\n  style,\n  ...rest\n}: ReviewCardProps) {\n  const id = React.useId();\n  const bodyRef = React.useRef<HTMLParagraphElement>(null);\n  const [open, setOpen] = React.useState(false);\n  const [clamped, setClamped] = React.useState(false);\n  const [voted, setVoted] = React.useState(false);\n\n  const max = 5;\n  const value = Math.min(max, Math.max(0, Math.round(rating * 2) / 2));\n  const clampLines = Math.max(1, Math.round(lines));\n  const hue = hash(name) % 360;\n  const votes = helpful + (voted ? 1 : 0);\n\n  React.useEffect(() => {\n    const el = bodyRef.current;\n    if (!el || typeof ResizeObserver === \"undefined\") return;\n    const ro = new ResizeObserver(() => {\n      if (el.dataset.open === \"true\") return;\n      setClamped(el.scrollHeight > el.clientHeight + 1);\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, [text, clampLines]);\n\n  const vars = {\n    \"--hb-l\": clampLines,\n    \"--hb-bg\": `hsl(${hue} 42% 30%)`,\n    \"--hb-fg\": `hsl(${hue} 70% 88%)`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <article className={`hb-rv ${className}`} style={vars} {...rest}>\n      <style href=\"hb-review-card\" precedence=\"default\">{css}</style>\n      <div className=\"hb-rv-top\">\n        <span className=\"hb-rv-av\" aria-hidden=\"true\">\n          {initials(name)}\n          {avatar && (\n            <span\n              className=\"hb-rv-img\"\n              style={{ backgroundImage: `url(\"${avatar.replace(/\"/g, \"%22\")}\")` }}\n            />\n          )}\n        </span>\n        <div className=\"hb-rv-who\">\n          <span className=\"hb-rv-name\">{name}</span>\n          {verified && (\n            <span className=\"hb-rv-ok\">\n              <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n                <path d=\"M5 12.5l4.5 4.5L19 7.5\" />\n              </svg>\n              Verified\n            </span>\n          )}\n        </div>\n        {date && <span className=\"hb-rv-date\">{date}</span>}\n      </div>\n      <div className=\"hb-rv-rate\">\n        <span className=\"hb-rv-stars\" role=\"img\" aria-label={`Rated ${value} out of ${max}`}>\n          {Array.from({ length: max }, (_, i) => {\n            const fill = Math.min(1, Math.max(0, value - i));\n            return (\n              <span key={i} className=\"hb-rv-star\" aria-hidden=\"true\">\n                <svg viewBox=\"0 0 24 24\" className=\"hb-rv-star-b\">\n                  <path d={starPath} />\n                </svg>\n                <span className=\"hb-rv-star-f\" style={{ width: `${fill * 100}%` }}>\n                  <svg viewBox=\"0 0 24 24\">\n                    <path d={starPath} />\n                  </svg>\n                </span>\n              </span>\n            );\n          })}\n        </span>\n        {title && <span className=\"hb-rv-title\">{title}</span>}\n      </div>\n      {text && (\n        <p ref={bodyRef} id={id} className=\"hb-rv-text\" data-open={open ? \"true\" : \"false\"}>\n          {text}\n        </p>\n      )}\n      <div className=\"hb-rv-foot\">\n        <button\n          type=\"button\"\n          className=\"hb-rv-btn\"\n          aria-pressed={voted}\n          onClick={() => setVoted((v) => !v)}\n        >\n          <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n            <path d=\"M7 11v9H4a1 1 0 01-1-1v-7a1 1 0 011-1h3zM7 11l4-7c1.7 0 2.7 1.2 2.4 2.9L13 10h5.3a2 2 0 011.97 2.35l-1.1 6A2 2 0 0117.2 20H7\" />\n          </svg>\n          <span>Helpful</span>\n          {votes > 0 && <span>{votes.toLocaleString(\"en-US\")}</span>}\n        </button>\n        {(clamped || open) && (\n          <button\n            type=\"button\"\n            className=\"hb-rv-more\"\n            aria-expanded={open}\n            aria-controls={id}\n            onClick={() => setOpen((o) => !o)}\n          >\n            {open ? \"Show less\" : \"Read more\"}\n          </button>\n        )}\n      </div>\n      <span className=\"hb-rv-sr\" role=\"status\" aria-live=\"polite\">\n        {voted ? `Marked helpful. ${votes} found this helpful.` : \"\"}\n      </span>\n    </article>\n  );\n}\n"
    }
  ]
}