{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "like-thumbs-pop",
  "type": "registry:component",
  "title": "Like Thumbs Pop",
  "description": "A thumbs-up that tilts back, pops forward and throws a fan of spark lines, with a rolling like count beside it.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "social",
    "like",
    "thumbs",
    "button",
    "sparks",
    "counter",
    "reaction"
  ],
  "docs": "https://hyperblur.dev/effects/like-thumbs-pop",
  "files": [
    {
      "path": "registry/hyperblur/like-thumbs-pop.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/like-thumbs-pop.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LikeThumbsPopProps extends React.HTMLAttributes<HTMLSpanElement> {\n  count?: number;\n  liked?: boolean;\n  defaultLiked?: boolean;\n  onLikeChange?: (liked: boolean, count: number) => void;\n  color?: string;\n  size?: number;\n  label?: string;\n}\n\nconst css = `\n.hb-qb2 {\n  position: relative;\n  display: inline-flex;\n  vertical-align: middle;\n  box-sizing: border-box;\n  font-family: inherit;\n}\n.hb-qb2 *, .hb-qb2 *::before, .hb-qb2 *::after { box-sizing: border-box; }\n.hb-qb2-btn {\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: calc(var(--hb-qb2-s) * 0.34);\n  margin: 0;\n  padding: calc(var(--hb-qb2-s) * 0.3) calc(var(--hb-qb2-s) * 0.62) calc(var(--hb-qb2-s) * 0.3) calc(var(--hb-qb2-s) * 0.5);\n  border: 1px solid #262626;\n  border-radius: calc(var(--hb-qb2-s) * 0.55);\n  background: #171717;\n  color: #8f8f8f;\n  font: inherit;\n  font-size: calc(var(--hb-qb2-s) * 0.6);\n  font-weight: 600;\n  line-height: 1;\n  cursor: pointer;\n  user-select: none;\n  touch-action: manipulation;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease, transform 0.12s ease;\n}\n.hb-qb2-btn:hover { border-color: #3a3a3a; color: #ededed; }\n.hb-qb2-btn:active { transform: scale(0.96); }\n.hb-qb2-btn:focus-visible { outline: 2px solid var(--hb-qb2-c); outline-offset: 3px; }\n.hb-qb2-btn[aria-pressed=\"true\"] {\n  border-color: color-mix(in srgb, var(--hb-qb2-c) 50%, #262626);\n  background: color-mix(in srgb, var(--hb-qb2-c) 10%, #171717);\n  color: #ededed;\n}\n.hb-qb2-ico {\n  position: relative;\n  display: inline-flex;\n  width: var(--hb-qb2-s);\n  height: var(--hb-qb2-s);\n  flex: none;\n}\n.hb-qb2-hand {\n  display: block;\n  width: 100%;\n  height: 100%;\n  transform-origin: 22% 88%;\n}\n.hb-qb2-hand svg {\n  display: block;\n  width: 100%;\n  height: 100%;\n  overflow: visible;\n  fill: transparent;\n  stroke: currentColor;\n  stroke-width: 1.7;\n  stroke-linejoin: round;\n  stroke-linecap: round;\n  transition: fill 0.2s ease, stroke 0.2s ease;\n}\n.hb-qb2-btn[aria-pressed=\"true\"] .hb-qb2-hand svg { fill: var(--hb-qb2-c); stroke: var(--hb-qb2-c); }\n.hb-qb2-btn[aria-pressed=\"true\"] .hb-qb2-hand .hb-qb2-cuff { fill: color-mix(in srgb, var(--hb-qb2-c) 55%, #0a0a0a); }\n.hb-qb2-hand[data-fx=\"like\"] { animation: hb-qb2-pop 0.8s cubic-bezier(0.3, 1.2, 0.5, 1); }\n.hb-qb2-hand[data-fx=\"unlike\"] { animation: hb-qb2-drop 0.35s ease-out; }\n@keyframes hb-qb2-pop {\n  0% { transform: rotate(0deg) scale(1); }\n  26% { transform: rotate(-30deg) translate(-6%, 8%) scale(0.9); }\n  56% { transform: rotate(12deg) translate(2%, -10%) scale(1.3); }\n  78% { transform: rotate(-4deg) scale(0.97); }\n  100% { transform: rotate(0deg) scale(1); }\n}\n@keyframes hb-qb2-drop {\n  0% { transform: rotate(0deg) scale(1.1); }\n  100% { transform: rotate(0deg) scale(1); }\n}\n.hb-qb2-sparks {\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n}\n.hb-qb2-sparks i {\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  width: calc(var(--hb-qb2-s) * 0.3);\n  height: 2px;\n  margin: -1px 0 0 calc(var(--hb-qb2-s) * -0.15);\n  border-radius: 2px;\n  background: var(--hb-qb2-c);\n  opacity: 0;\n  animation: hb-qb2-spark 0.55s ease-out var(--hb-qb2-d) forwards;\n}\n@keyframes hb-qb2-spark {\n  0% { opacity: 0; transform: rotate(var(--hb-qb2-a)) translateX(calc(var(--hb-qb2-s) * 0.55)) scaleX(0.3); }\n  30% { opacity: 1; }\n  100% { opacity: 0; transform: rotate(var(--hb-qb2-a)) translateX(calc(var(--hb-qb2-s) * 1.05)) scaleX(1); }\n}\n.hb-qb2-count {\n  display: inline-flex;\n  font-variant-numeric: tabular-nums;\n  white-space: pre;\n}\n.hb-qb2-roll {\n  display: inline-grid;\n  overflow: hidden;\n  line-height: 1.25;\n  margin: -0.125em 0;\n}\n.hb-qb2-roll > span { grid-area: 1 / 1; display: block; }\n.hb-qb2-in { animation: hb-qb2-up-in 0.38s cubic-bezier(0.3, 1.3, 0.5, 1) both; }\n.hb-qb2-out { animation: hb-qb2-up-out 0.3s ease-in both; }\n.hb-qb2-roll[data-up=\"false\"] .hb-qb2-in { animation-name: hb-qb2-down-in; }\n.hb-qb2-roll[data-up=\"false\"] .hb-qb2-out { animation-name: hb-qb2-down-out; }\n@keyframes hb-qb2-up-in {\n  from { transform: translateY(100%); opacity: 0; }\n  to { transform: translateY(0); opacity: 1; }\n}\n@keyframes hb-qb2-up-out {\n  from { transform: translateY(0); opacity: 1; }\n  to { transform: translateY(-100%); opacity: 0; }\n}\n@keyframes hb-qb2-down-in {\n  from { transform: translateY(-100%); opacity: 0; }\n  to { transform: translateY(0); opacity: 1; }\n}\n@keyframes hb-qb2-down-out {\n  from { transform: translateY(0); opacity: 1; }\n  to { transform: translateY(100%); opacity: 0; }\n}\n.hb-qb2-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@media (prefers-reduced-motion: reduce) {\n  .hb-qb2-btn, .hb-qb2-hand svg { transition: none; }\n  .hb-qb2-hand[data-fx] { animation: none; }\n  .hb-qb2-sparks { display: none; }\n  .hb-qb2-out { display: none; }\n  .hb-qb2-in { animation: none; }\n}\n`;\n\nconst cuff = \"M3.2 11.2h3.6a.9.9 0 01.9.9v8a.9.9 0 01-.9.9H3.2a.9.9 0 01-.9-.9v-8a.9.9 0 01.9-.9z\";\nconst hand =\n  \"M9.4 11.4l3-6.6c.5-1.1 1.6-1.7 2.7-1.3 1.1.4 1.7 1.5 1.5 2.7l-.6 3.4h4.2a2 2 0 011.95 2.45l-1.4 6.3a2 2 0 01-1.95 1.55H11.4a2 2 0 01-2-2z\";\n\nconst SPARKS = [-168, -138, -108, -78, -48, -18].map((a, i) => ({\n  a,\n  d: 240 + ((i * 53) % 90),\n}));\n\ninterface RollState {\n  value: number;\n  prev: number;\n  id: number;\n  live: boolean;\n}\n\nfunction Roll({ value }: { value: number }) {\n  const [view, setView] = React.useState<RollState>({ value, prev: value, id: 0, live: false });\n  if (view.value !== value) {\n    setView({ value, prev: view.value, id: view.id + 1, live: true });\n  }\n  const to = value.toLocaleString(\"en-US\");\n  if (!view.live) {\n    return (\n      <span className=\"hb-qb2-count\" aria-hidden=\"true\">\n        {to}\n      </span>\n    );\n  }\n  const from = view.prev.toLocaleString(\"en-US\");\n  let p = 0;\n  while (p < from.length && p < to.length && from[p] === to[p]) p++;\n  return (\n    <span className=\"hb-qb2-count\" aria-hidden=\"true\">\n      {to.slice(0, p)}\n      <span key={view.id} className=\"hb-qb2-roll\" data-up={value > view.prev ? \"true\" : \"false\"}>\n        <span className=\"hb-qb2-out\">{from.slice(p)}</span>\n        <span\n          className=\"hb-qb2-in\"\n          onAnimationEnd={() => setView((v) => (v.live ? { ...v, live: false } : v))}\n        >\n          {to.slice(p)}\n        </span>\n      </span>\n    </span>\n  );\n}\n\nexport function LikeThumbsPop({\n  count = 0,\n  liked,\n  defaultLiked = false,\n  onLikeChange,\n  color = \"#2f7bff\",\n  size = 22,\n  label = \"Like\",\n  className = \"\",\n  style,\n  ...rest\n}: LikeThumbsPopProps) {\n  const controlled = liked !== undefined;\n  const [inner, setInner] = React.useState(defaultLiked);\n  const current = controlled ? liked : inner;\n  const [base] = React.useState(current);\n  const [seen, setSeen] = React.useState({ liked: current, pulse: 0 });\n\n  if (seen.liked !== current) {\n    setSeen({ liked: current, pulse: seen.pulse + 1 });\n  }\n\n  const offset = current === base ? 0 : current ? 1 : -1;\n  const total = Math.max(0, count + offset);\n\n  function toggle() {\n    const next = !current;\n    if (!controlled) setInner(next);\n    const nextOffset = next === base ? 0 : next ? 1 : -1;\n    onLikeChange?.(next, Math.max(0, count + nextOffset));\n  }\n\n  const vars = {\n    \"--hb-qb2-s\": `${size}px`,\n    \"--hb-qb2-c\": color,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <span className={`hb-qb2 ${className}`} style={vars} {...rest}>\n      <style href=\"hb-like-thumbs-pop\" precedence=\"default\">{css}</style>\n      <button type=\"button\" className=\"hb-qb2-btn\" aria-pressed={current} aria-label={label} onClick={toggle}>\n        <span className=\"hb-qb2-ico\" aria-hidden=\"true\">\n          <span\n            key={`h${seen.pulse}`}\n            className=\"hb-qb2-hand\"\n            data-fx={seen.pulse === 0 ? undefined : current ? \"like\" : \"unlike\"}\n          >\n            <svg viewBox=\"0 0 24 24\">\n              <path className=\"hb-qb2-cuff\" d={cuff} />\n              <path d={hand} />\n            </svg>\n          </span>\n          {seen.pulse > 0 && current && (\n            <span key={`s${seen.pulse}`} className=\"hb-qb2-sparks\">\n              {SPARKS.map((s, i) => (\n                <i\n                  key={i}\n                  style={{ \"--hb-qb2-a\": `${s.a}deg`, \"--hb-qb2-d\": `${s.d}ms` } as React.CSSProperties}\n                />\n              ))}\n            </span>\n          )}\n        </span>\n        <Roll value={total} />\n      </button>\n      <span className=\"hb-qb2-sr\" role=\"status\" aria-live=\"polite\">\n        {`${total.toLocaleString(\"en-US\")} ${total === 1 ? \"like\" : \"likes\"}`}\n      </span>\n    </span>\n  );\n}\n"
    }
  ]
}