{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "like-reaction-picker",
  "type": "registry:component",
  "title": "Like Reaction Picker",
  "description": "A react button that opens a row of five face reactions on click or press and hold. The hovered face scales up and the choice replaces the button label.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "social",
    "reaction",
    "picker",
    "emoji",
    "faces",
    "like",
    "popover"
  ],
  "docs": "https://hyperblur.dev/effects/like-reaction-picker",
  "files": [
    {
      "path": "registry/hyperblur/like-reaction-picker.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/like-reaction-picker.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type ReactionId = \"like\" | \"love\" | \"haha\" | \"wow\" | \"sad\";\n\nexport interface LikeReactionPickerProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n  value?: ReactionId | null;\n  defaultValue?: ReactionId | null;\n  onChange?: (value: ReactionId | null) => void;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  accent?: string;\n  label?: string;\n  holdDelay?: number;\n}\n\nconst css = `\n.hb-qb3 {\n  position: relative;\n  display: inline-block;\n  box-sizing: border-box;\n  font-family: inherit;\n  --hb-qb3-a: #2f7bff;\n}\n.hb-qb3 *, .hb-qb3 *::before, .hb-qb3 *::after { box-sizing: border-box; }\n.hb-qb3-btn {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  height: 36px;\n  margin: 0;\n  padding: 0 14px 0 11px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  background: #171717;\n  color: #a1a1a1;\n  font: inherit;\n  font-size: 13px;\n  font-weight: 600;\n  line-height: 1;\n  white-space: nowrap;\n  cursor: pointer;\n  user-select: none;\n  -webkit-user-select: none;\n  -webkit-touch-callout: none;\n  touch-action: manipulation;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, transform 0.12s ease;\n}\n.hb-qb3-btn:hover { border-color: #3a3a3a; color: #ededed; }\n.hb-qb3-btn:active { transform: scale(0.96); }\n.hb-qb3-btn:focus-visible { outline: 2px solid var(--hb-qb3-a); outline-offset: 2px; }\n.hb-qb3-btn[data-on=\"true\"] {\n  border-color: color-mix(in srgb, var(--hb-qb3-t) 40%, #262626);\n  background: color-mix(in srgb, var(--hb-qb3-t) 9%, #171717);\n  color: var(--hb-qb3-t);\n}\n.hb-qb3-glyph {\n  display: inline-flex;\n  width: 20px;\n  height: 20px;\n  flex: none;\n}\n.hb-qb3-glyph svg {\n  display: block;\n  width: 100%;\n  height: 100%;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 1.8;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n.hb-qb3-glyph[data-face=\"true\"] svg { fill: none; stroke: none; }\n.hb-qb3-glyph[data-face=\"true\"] { animation: hb-qb3-land 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }\n@keyframes hb-qb3-land {\n  0% { transform: scale(0.4) rotate(-20deg); }\n  100% { transform: scale(1) rotate(0deg); }\n}\n.hb-qb3-bubble {\n  position: absolute;\n  left: 0;\n  bottom: calc(100% + 10px);\n  z-index: 5;\n  display: flex;\n  align-items: flex-end;\n  gap: 2px;\n  padding: 6px 8px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  background: #171717;\n  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);\n  transform-origin: 20% 100%;\n  animation: hb-qb3-bubble 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);\n}\n@keyframes hb-qb3-bubble {\n  from { opacity: 0; transform: translateY(8px) scale(0.9); }\n  to { opacity: 1; transform: translateY(0) scale(1); }\n}\n.hb-qb3-slot {\n  position: relative;\n  display: block;\n  width: 34px;\n  height: 34px;\n}\n.hb-qb3-item {\n  position: relative;\n  display: block;\n  width: 100%;\n  height: 100%;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  background: transparent;\n  cursor: pointer;\n  transform-origin: 50% 100%;\n  touch-action: manipulation;\n  -webkit-tap-highlight-color: transparent;\n  transition: transform 0.2s cubic-bezier(0.3, 1.5, 0.5, 1);\n  animation: hb-qb3-in 0.4s cubic-bezier(0.3, 1.5, 0.5, 1) backwards;\n  animation-delay: calc(var(--hb-qb3-i) * 45ms);\n}\n.hb-qb3-item svg { display: block; width: 100%; height: 100%; }\n.hb-qb3-item:focus-visible { outline: 2px solid var(--hb-qb3-a); outline-offset: 2px; }\n.hb-qb3-slot[data-active=\"true\"] .hb-qb3-item { transform: translateY(-9px) scale(1.5); }\n.hb-qb3-item[aria-checked=\"true\"]::after {\n  content: \"\";\n  position: absolute;\n  left: 50%;\n  bottom: -6px;\n  width: 4px;\n  height: 4px;\n  margin-left: -2px;\n  border-radius: 50%;\n  background: var(--hb-qb3-a);\n}\n@keyframes hb-qb3-in {\n  from { opacity: 0; transform: translateY(16px) scale(0.4); }\n  to { opacity: 1; transform: translateY(0) scale(1); }\n}\n.hb-qb3-tip {\n  position: absolute;\n  left: 50%;\n  bottom: calc(100% + 28px);\n  padding: 4px 8px;\n  border-radius: 999px;\n  background: #ededed;\n  color: #0a0a0a;\n  font-size: 11px;\n  font-weight: 600;\n  line-height: 1;\n  white-space: nowrap;\n  pointer-events: none;\n  opacity: 0;\n  transform: translate(-50%, 4px);\n  transition: opacity 0.15s ease, transform 0.15s ease;\n}\n.hb-qb3-slot[data-active=\"true\"] .hb-qb3-tip { opacity: 1; transform: translate(-50%, 0); }\n.hb-qb3-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-qb3-btn, .hb-qb3-item, .hb-qb3-tip { transition: none; }\n  .hb-qb3-bubble, .hb-qb3-item, .hb-qb3-glyph[data-face=\"true\"] { animation: none; }\n}\n`;\n\nconst ink = \"#3a2a10\";\nconst skin = \"#ffcf4a\";\nconst heart =\n  \"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z\";\n\nconst reactions: { id: ReactionId; name: string; tone: string }[] = [\n  { id: \"like\", name: \"Like\", tone: \"#5aa2ff\" },\n  { id: \"love\", name: \"Love\", tone: \"#ff5a76\" },\n  { id: \"haha\", name: \"Haha\", tone: \"#ffc83d\" },\n  { id: \"wow\", name: \"Wow\", tone: \"#ffc83d\" },\n  { id: \"sad\", name: \"Sad\", tone: \"#ffc83d\" },\n];\n\nfunction Face({ id }: { id: ReactionId }) {\n  let features: React.ReactNode;\n  switch (id) {\n    case \"love\":\n      features = (\n        <>\n          <path transform=\"translate(7.2 8.7) scale(0.34)\" d={heart} fill=\"#ff3b5c\" />\n          <path transform=\"translate(16.7 8.7) scale(0.34)\" d={heart} fill=\"#ff3b5c\" />\n          <path d=\"M10.2 18.6c1.7 4.2 10 4.2 11.6 0\" fill=\"none\" stroke={ink} strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n        </>\n      );\n      break;\n    case \"haha\":\n      features = (\n        <>\n          <path d=\"M8.2 14.2q3-3.8 6 0M17.8 14.2q3-3.8 6 0\" fill=\"none\" stroke={ink} strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n          <path d=\"M9 18h14c0 4.8-3 7.6-7 7.6S9 22.8 9 18z\" fill={ink} />\n          <path d=\"M12.2 23.6c1.2-1.8 6.4-1.8 7.6 0-1.4 1.3-6.2 1.3-7.6 0z\" fill=\"#ff6f7d\" />\n        </>\n      );\n      break;\n    case \"wow\":\n      features = (\n        <>\n          <path d=\"M8.4 9.6q2.6-2.2 5.2-.4M18.4 9.2q2.6-1.8 5.2.4\" fill=\"none\" stroke={ink} strokeWidth=\"1.6\" strokeLinecap=\"round\" />\n          <circle cx=\"11.2\" cy=\"14\" r=\"2\" fill={ink} />\n          <circle cx=\"20.8\" cy=\"14\" r=\"2\" fill={ink} />\n          <ellipse cx=\"16\" cy=\"22.4\" rx=\"3\" ry=\"3.8\" fill={ink} />\n        </>\n      );\n      break;\n    case \"sad\":\n      features = (\n        <>\n          <path d=\"M8.4 12.2l5.4-2M23.6 12.2l-5.4-2\" fill=\"none\" stroke={ink} strokeWidth=\"1.6\" strokeLinecap=\"round\" />\n          <circle cx=\"11.4\" cy=\"15\" r=\"1.8\" fill={ink} />\n          <circle cx=\"20.6\" cy=\"15\" r=\"1.8\" fill={ink} />\n          <path d=\"M11 23.4c1.6-3 8.4-3 10 0\" fill=\"none\" stroke={ink} strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n          <path d=\"M23.2 17.6c1.2 1.6 1.8 2.7 1.8 3.5a1.8 1.8 0 11-3.6 0c0-.8.6-1.9 1.8-3.5z\" fill=\"#5ab4ff\" />\n        </>\n      );\n      break;\n    default:\n      features = (\n        <>\n          <circle cx=\"11.2\" cy=\"13.4\" r=\"1.8\" fill={ink} />\n          <circle cx=\"20.8\" cy=\"13.4\" r=\"1.8\" fill={ink} />\n          <circle cx=\"8.2\" cy=\"18.6\" r=\"2\" fill=\"#ff7a5a\" opacity=\"0.4\" />\n          <circle cx=\"23.8\" cy=\"18.6\" r=\"2\" fill=\"#ff7a5a\" opacity=\"0.4\" />\n          <path d=\"M10.4 18.8c1.4 3.6 9.8 3.6 11.2 0\" fill=\"none\" stroke={ink} strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n        </>\n      );\n  }\n  return (\n    <svg viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n      <circle cx=\"16\" cy=\"16\" r=\"14.5\" fill={skin} />\n      <path d=\"M6 10.5C9 4.8 20.5 3 26 9.5 22 6.8 12 6.6 6 10.5z\" fill=\"#fff\" opacity=\"0.28\" />\n      {features}\n    </svg>\n  );\n}\n\nexport function LikeReactionPicker({\n  value,\n  defaultValue = null,\n  onChange,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  accent = \"#2f7bff\",\n  label = \"Like\",\n  holdDelay = 380,\n  className = \"\",\n  style,\n  ...rest\n}: LikeReactionPickerProps) {\n  const valueControlled = value !== undefined;\n  const [innerValue, setInnerValue] = React.useState<ReactionId | null>(defaultValue);\n  const current = valueControlled ? value : innerValue;\n\n  const openControlled = open !== undefined;\n  const [innerOpen, setInnerOpen] = React.useState(defaultOpen);\n  const isOpen = openControlled ? open : innerOpen;\n\n  const [active, setActive] = React.useState(-1);\n\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const btnRef = React.useRef<HTMLButtonElement>(null);\n  const bubbleRef = React.useRef<HTMLDivElement>(null);\n  const timer = React.useRef<number | undefined>(undefined);\n  const held = React.useRef(false);\n  const pending = React.useRef<number | null>(null);\n\n  function setOpen(next: boolean) {\n    if (!openControlled) setInnerOpen(next);\n    if (!next) setActive(-1);\n    onOpenChange?.(next);\n  }\n\n  function choose(id: ReactionId) {\n    const next = current === id ? null : id;\n    if (!valueControlled) setInnerValue(next);\n    onChange?.(next);\n    if (bubbleRef.current?.contains(document.activeElement)) btnRef.current?.focus();\n    setOpen(false);\n  }\n\n  function items() {\n    return Array.from(bubbleRef.current?.querySelectorAll<HTMLButtonElement>(\"[role='menuitemradio']\") ?? []);\n  }\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  React.useEffect(() => {\n    if (isOpen && pending.current !== null) {\n      const list = items();\n      list[Math.min(pending.current, list.length - 1)]?.focus();\n      pending.current = null;\n    }\n  }, [isOpen]);\n\n  React.useEffect(() => {\n    if (!isOpen) return;\n    function down(e: PointerEvent) {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n        if (!openControlled) setInnerOpen(false);\n        setActive(-1);\n        onOpenChange?.(false);\n      }\n    }\n    function key(e: KeyboardEvent) {\n      if (e.key === \"Escape\") {\n        if (!openControlled) setInnerOpen(false);\n        setActive(-1);\n        onOpenChange?.(false);\n        if (rootRef.current?.contains(document.activeElement)) btnRef.current?.focus();\n      }\n    }\n    document.addEventListener(\"pointerdown\", down);\n    document.addEventListener(\"keydown\", key);\n    return () => {\n      document.removeEventListener(\"pointerdown\", down);\n      document.removeEventListener(\"keydown\", key);\n    };\n  }, [isOpen, openControlled, onOpenChange]);\n\n  function startHold(e: React.PointerEvent) {\n    if (e.pointerType === \"mouse\" && e.button !== 0) return;\n    held.current = false;\n    window.clearTimeout(timer.current);\n    timer.current = window.setTimeout(() => {\n      held.current = true;\n      setOpen(true);\n    }, holdDelay);\n  }\n\n  function endHold() {\n    window.clearTimeout(timer.current);\n  }\n\n  function onBaseClick(e: React.MouseEvent) {\n    if (held.current) {\n      held.current = false;\n      return;\n    }\n    if (e.detail === 0 && !isOpen) {\n      const at = reactions.findIndex((r) => r.id === current);\n      pending.current = at < 0 ? 0 : at;\n    }\n    setOpen(!isOpen);\n  }\n\n  function onBaseKey(e: React.KeyboardEvent) {\n    if (e.key === \"ArrowUp\" || e.key === \"ArrowRight\" || e.key === \"ArrowDown\") {\n      e.preventDefault();\n      if (isOpen) {\n        const list = items();\n        const at = reactions.findIndex((r) => r.id === current);\n        list[at < 0 ? 0 : at]?.focus();\n      } else {\n        const at = reactions.findIndex((r) => r.id === current);\n        pending.current = at < 0 ? 0 : at;\n        setOpen(true);\n      }\n    }\n  }\n\n  function onItemKey(e: React.KeyboardEvent, index: number) {\n    const list = items();\n    let target = -1;\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") target = (index + 1) % list.length;\n    else if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\") target = (index - 1 + list.length) % list.length;\n    else if (e.key === \"Home\") target = 0;\n    else if (e.key === \"End\") target = list.length - 1;\n    else if (e.key === \"Tab\") setOpen(false);\n    if (target >= 0) {\n      e.preventDefault();\n      list[target]?.focus();\n    }\n  }\n\n  const picked = reactions.find((r) => r.id === current);\n  const vars = { \"--hb-qb3-a\": accent, \"--hb-qb3-t\": picked?.tone ?? accent, ...style } as React.CSSProperties;\n\n  return (\n    <div ref={rootRef} className={`hb-qb3 ${className}`} style={vars} {...rest}>\n      <style href=\"hb-like-reaction-picker\" precedence=\"default\">{css}</style>\n      <button\n        ref={btnRef}\n        type=\"button\"\n        className=\"hb-qb3-btn\"\n        data-on={picked ? \"true\" : \"false\"}\n        aria-haspopup=\"menu\"\n        aria-expanded={isOpen}\n        aria-label={picked ? `${label}: ${picked.name}` : label}\n        onClick={onBaseClick}\n        onKeyDown={onBaseKey}\n        onPointerDown={startHold}\n        onPointerUp={endHold}\n        onPointerLeave={endHold}\n        onPointerCancel={endHold}\n        onContextMenu={(e) => e.preventDefault()}\n      >\n        {picked ? (\n          <span key={picked.id} className=\"hb-qb3-glyph\" data-face=\"true\" aria-hidden=\"true\">\n            <Face id={picked.id} />\n          </span>\n        ) : (\n          <span className=\"hb-qb3-glyph\" aria-hidden=\"true\">\n            <svg viewBox=\"0 0 24 24\">\n              <path d=\"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\" />\n              <path d=\"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            </svg>\n          </span>\n        )}\n        <span>{picked ? picked.name : label}</span>\n      </button>\n      {isOpen && (\n        <div ref={bubbleRef} role=\"menu\" aria-label=\"Choose a reaction\" className=\"hb-qb3-bubble\" onPointerLeave={() => setActive(-1)}>\n          {reactions.map((r, i) => (\n            <span key={r.id} className=\"hb-qb3-slot\" data-active={active === i ? \"true\" : \"false\"}>\n              <button\n                type=\"button\"\n                role=\"menuitemradio\"\n                aria-checked={current === r.id}\n                aria-label={r.name}\n                className=\"hb-qb3-item\"\n                style={{ \"--hb-qb3-i\": i } as React.CSSProperties}\n                onPointerEnter={() => setActive(i)}\n                onFocus={() => setActive(i)}\n                onBlur={() => setActive(-1)}\n                onKeyDown={(e) => onItemKey(e, i)}\n                onClick={() => choose(r.id)}\n              >\n                <Face id={r.id} />\n              </button>\n              <span className=\"hb-qb3-tip\" aria-hidden=\"true\">\n                {r.name}\n              </span>\n            </span>\n          ))}\n        </div>\n      )}\n      <span className=\"hb-qb3-sr\" role=\"status\" aria-live=\"polite\">\n        {picked ? `Reacted with ${picked.name}` : \"\"}\n      </span>\n    </div>\n  );\n}\n"
    }
  ]
}