{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-hold-ring",
  "type": "registry:component",
  "title": "Button Hold Ring",
  "description": "A round hold-to-fire button with a tick-marked progress ring that winds up while held and unwinds faster when released early. The button rumbles harder as it charges and bursts into a check when it fires.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "hold",
    "progress ring",
    "long press",
    "go live",
    "confirm"
  ],
  "docs": "https://hyperblur.dev/effects/button-hold-ring",
  "files": [
    {
      "path": "registry/hyperblur/button-hold-ring.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-hold-ring.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonHoldRingProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"onProgress\"> {\n  label?: string;\n  hint?: string;\n  holdingLabel?: string;\n  firedLabel?: string;\n  firedHint?: string;\n  icon?: React.ReactNode;\n  duration?: number;\n  resetAfter?: number;\n  size?: number;\n  accent?: string;\n  disabled?: boolean;\n  onFire?: () => void;\n  onProgress?: (progress: number) => void;\n}\n\nconst css = `\n.hb-xb2 {\n  --hb-xb2-c: #ff4d5e;\n  --hb-xb2-s: 64px;\n  --hb-xb2-a: 0px;\n  display: inline-flex;\n  align-items: center;\n  gap: 14px;\n  box-sizing: border-box;\n  font-family: inherit;\n  color: #ededed;\n}\n.hb-xb2 *, .hb-xb2 *::before, .hb-xb2 *::after { box-sizing: border-box; }\n.hb-xb2-wrap { position: relative; width: calc(var(--hb-xb2-s) + 16px); height: calc(var(--hb-xb2-s) + 16px); flex: none; display: grid; place-items: center; }\n.hb-xb2-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; pointer-events: none; }\n.hb-xb2-track { fill: none; stroke: #232323; stroke-width: 3; }\n.hb-xb2-prog { fill: none; stroke: var(--hb-xb2-c); stroke-width: 3; stroke-linecap: round; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--hb-xb2-c) 70%, transparent)); }\n.hb-xb2-ticks line { stroke: #3a3a3a; stroke-width: 1.4; stroke-linecap: round; }\n.hb-xb2-btn {\n  position: relative;\n  width: var(--hb-xb2-s);\n  height: var(--hb-xb2-s);\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  display: grid;\n  place-items: center;\n  color: #f5f5f5;\n  font: inherit;\n  cursor: pointer;\n  background: radial-gradient(100% 100% at 50% 0%, #2b2b2b 0%, #161616 70%);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -2px 6px rgba(0, 0, 0, 0.6), 0 8px 20px -8px rgba(0, 0, 0, 0.9), 0 0 0 1px #2a2a2a;\n  touch-action: none;\n  user-select: none;\n  -webkit-user-select: none;\n  -webkit-tap-highlight-color: transparent;\n  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, background 0.3s ease;\n}\n.hb-xb2-btn::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  border-radius: 50%;\n  background: radial-gradient(circle at 50% 50%, var(--hb-xb2-c), color-mix(in srgb, var(--hb-xb2-c) 60%, #000));\n  opacity: var(--hb-xb2-o, 0);\n  transform: scale(var(--hb-xb2-o, 0));\n  transition: opacity 0.12s linear;\n}\n.hb-xb2[data-state=\"holding\"][data-pressed=\"true\"] .hb-xb2-btn { transform: scale(0.94); animation: hb-xb2-rumble 0.09s linear infinite; }\n.hb-xb2[data-state=\"fired\"] .hb-xb2-btn { background: var(--hb-xb2-c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 0 1px var(--hb-xb2-c), 0 0 34px -4px var(--hb-xb2-c); }\n.hb-xb2-btn:focus-visible { outline: 2px solid var(--hb-xb2-c); outline-offset: 10px; }\n.hb-xb2-btn:disabled { cursor: not-allowed; opacity: 0.45; }\n.hb-xb2-ico { position: relative; display: grid; place-items: center; transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease; }\n.hb-xb2-ico svg { width: calc(var(--hb-xb2-s) * 0.38); height: calc(var(--hb-xb2-s) * 0.38); fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }\n.hb-xb2-ok { position: absolute; opacity: 0; transform: scale(0.3); }\n.hb-xb2[data-state=\"fired\"] .hb-xb2-ico:not(.hb-xb2-ok) { opacity: 0; transform: scale(0.3); }\n.hb-xb2[data-state=\"fired\"] .hb-xb2-ok { opacity: 1; transform: none; }\n.hb-xb2-ok path { stroke-dasharray: 24; stroke-dashoffset: 24; stroke-width: 2.6; }\n.hb-xb2[data-state=\"fired\"] .hb-xb2-ok path { animation: hb-xb2-draw 0.4s cubic-bezier(0.65, 0, 0.35, 1) 0.08s forwards; }\n.hb-xb2-burst { position: absolute; inset: 8px; border-radius: 50%; border: 2px solid var(--hb-xb2-c); opacity: 0; pointer-events: none; }\n.hb-xb2[data-state=\"fired\"] .hb-xb2-burst { animation: hb-xb2-burst 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards; }\n.hb-xb2[data-state=\"fired\"] .hb-xb2-burst + .hb-xb2-burst { animation-delay: 0.12s; }\n.hb-xb2-txt { display: grid; min-width: 0; }\n.hb-xb2-t { grid-area: 1 / 1; display: flex; flex-direction: column; gap: 3px; opacity: 0; transform: translateY(6px); transition: opacity 0.25s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1); white-space: nowrap; }\n.hb-xb2-t[data-on=\"true\"] { opacity: 1; transform: none; }\n.hb-xb2-l { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }\n.hb-xb2-h { font-size: 12px; color: #8f8f8f; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 6px; }\n.hb-xb2-kbd { font-family: var(--font-mono, ui-monospace, monospace); font-size: 10px; padding: 1px 5px; border-radius: 4px; border: 1px solid #2c2c2c; background: #151515; color: #a1a1a1; }\n.hb-xb2-live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--hb-xb2-c); box-shadow: 0 0 0 0 var(--hb-xb2-c); animation: hb-xb2-ping 1.4s ease-out infinite; }\n@keyframes hb-xb2-rumble {\n  0% { translate: 0 0; }\n  25% { translate: var(--hb-xb2-a) calc(var(--hb-xb2-a) * -0.5); }\n  50% { translate: calc(var(--hb-xb2-a) * -1) 0; }\n  75% { translate: calc(var(--hb-xb2-a) * 0.5) var(--hb-xb2-a); }\n  100% { translate: 0 0; }\n}\n@keyframes hb-xb2-draw { to { stroke-dashoffset: 0; } }\n@keyframes hb-xb2-burst { 0% { opacity: 0.9; transform: scale(0.9); } 100% { opacity: 0; transform: scale(1.7); } }\n@keyframes hb-xb2-ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hb-xb2-c) 70%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xb2[data-state=\"holding\"][data-pressed=\"true\"] .hb-xb2-btn { animation: none; }\n  .hb-xb2-burst, .hb-xb2-live { animation: none !important; }\n  .hb-xb2 *, .hb-xb2-btn { transition-duration: 0.01s !important; }\n  .hb-xb2[data-state=\"fired\"] .hb-xb2-ok path { animation: none; stroke-dashoffset: 0; }\n}\n`;\n\nconst broadcast = (\n  <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n    <circle cx=\"12\" cy=\"12\" r=\"2.2\" />\n    <path d=\"M7.8 16.2a6 6 0 0 1 0-8.4M16.2 7.8a6 6 0 0 1 0 8.4M5 19a10 10 0 0 1 0-14M19 5a10 10 0 0 1 0 14\" />\n  </svg>\n);\n\nexport function ButtonHoldRing({\n  label = \"Hold to go live\",\n  hint = \"Hold for 1.2 seconds\",\n  holdingLabel = \"Keep holding\",\n  firedLabel = \"You're live\",\n  firedHint = \"Streaming now\",\n  icon = broadcast,\n  duration = 1200,\n  resetAfter = 2200,\n  size = 64,\n  accent = \"#ff4d5e\",\n  disabled = false,\n  onFire,\n  onProgress,\n  className = \"\",\n  style,\n  ...rest\n}: ButtonHoldRingProps) {\n  const [progress, setProgress] = React.useState(0);\n  const [state, setState] = React.useState<\"idle\" | \"holding\" | \"fired\">(\"idle\");\n  const [pressed, setPressed] = React.useState(false);\n  const raf = React.useRef(0);\n  const holding = React.useRef(false);\n  const value = React.useRef(0);\n  const last = React.useRef(0);\n  const timer = React.useRef(0);\n  const cbs = React.useRef({ onFire, onProgress });\n\n  React.useEffect(() => {\n    cbs.current = { onFire, onProgress };\n  });\n\n  React.useEffect(\n    () => () => {\n      cancelAnimationFrame(raf.current);\n      window.clearTimeout(timer.current);\n    },\n    [],\n  );\n\n  const run = () => {\n    function tick(now: number) {\n      const dt = last.current ? now - last.current : 16;\n      last.current = now;\n      const dir = holding.current ? 1 : -2.4;\n      const next = Math.max(0, Math.min(1, value.current + (dt / duration) * dir));\n      value.current = next;\n      setProgress(next);\n      cbs.current.onProgress?.(next);\n      if (next >= 1) {\n        holding.current = false;\n        setPressed(false);\n        setState(\"fired\");\n        cbs.current.onFire?.();\n        timer.current = window.setTimeout(() => {\n          value.current = 0;\n          setProgress(0);\n          setState(\"idle\");\n        }, resetAfter);\n        return;\n      }\n      if (next <= 0 && !holding.current) {\n        setState(\"idle\");\n        return;\n      }\n      raf.current = requestAnimationFrame(tick);\n    }\n    raf.current = requestAnimationFrame(tick);\n  };\n\n  const begin = () => {\n    if (disabled || state === \"fired\" || holding.current) return;\n    holding.current = true;\n    setPressed(true);\n    setState(\"holding\");\n    cancelAnimationFrame(raf.current);\n    last.current = 0;\n    run();\n  };\n\n  const end = () => {\n    setPressed(false);\n    if (!holding.current) return;\n    holding.current = false;\n  };\n\n  const r = 44;\n  const c = 2 * Math.PI * r;\n  const ticks = Array.from({ length: 24 }, (_, i) => {\n    const a = (i / 24) * Math.PI * 2;\n    return { x1: (50 + Math.cos(a) * 48.5).toFixed(2), y1: (50 + Math.sin(a) * 48.5).toFixed(2), x2: (50 + Math.cos(a) * 50).toFixed(2), y2: (50 + Math.sin(a) * 50).toFixed(2) };\n  });\n  const remain = ((1 - progress) * duration) / 1000;\n\n  const vars = {\n    \"--hb-xb2-c\": accent,\n    \"--hb-xb2-s\": `${size}px`,\n    \"--hb-xb2-a\": `${(progress * 1.6).toFixed(2)}px`,\n    \"--hb-xb2-o\": (state === \"fired\" ? 0 : progress * 0.35).toFixed(3),\n  } as React.CSSProperties;\n\n  return (\n    <div className={`hb-xb2 ${className}`.trim()} data-state={state} data-pressed={pressed ? \"true\" : \"false\"} style={{ ...vars, ...style }} {...rest}>\n      <style href=\"hb-button-hold-ring\" precedence=\"default\">{css}</style>\n      <div className=\"hb-xb2-wrap\">\n        <svg className=\"hb-xb2-ring\" viewBox=\"0 0 100 100\" aria-hidden=\"true\">\n          <g className=\"hb-xb2-ticks\">\n            {ticks.map((t, i) => (\n              <line key={i} x1={t.x1} y1={t.y1} x2={t.x2} y2={t.y2} />\n            ))}\n          </g>\n          <circle className=\"hb-xb2-track\" cx=\"50\" cy=\"50\" r={r} />\n          <circle\n            className=\"hb-xb2-prog\"\n            cx=\"50\"\n            cy=\"50\"\n            r={r}\n            strokeDasharray={c.toFixed(2)}\n            strokeDashoffset={(c * (1 - (state === \"fired\" ? 1 : progress))).toFixed(2)}\n            opacity={progress > 0 || state === \"fired\" ? 1 : 0}\n          />\n        </svg>\n        <span className=\"hb-xb2-burst\" aria-hidden=\"true\" />\n        <span className=\"hb-xb2-burst\" aria-hidden=\"true\" />\n        <button\n          type=\"button\"\n          className=\"hb-xb2-btn\"\n          aria-label={state === \"fired\" ? firedLabel : `${label}. Press and hold.`}\n          disabled={disabled}\n          onPointerDown={(e) => {\n            e.currentTarget.setPointerCapture(e.pointerId);\n            begin();\n          }}\n          onPointerUp={end}\n          onPointerCancel={end}\n          onLostPointerCapture={end}\n          onContextMenu={(e) => e.preventDefault()}\n          onKeyDown={(e) => {\n            if (e.key === \" \" || e.key === \"Enter\") {\n              e.preventDefault();\n              if (!e.repeat) begin();\n            }\n          }}\n          onKeyUp={(e) => {\n            if (e.key === \" \" || e.key === \"Enter\") end();\n          }}\n          onBlur={end}\n        >\n          <span className=\"hb-xb2-ico\">{icon}</span>\n          <span className=\"hb-xb2-ico hb-xb2-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          </span>\n        </button>\n      </div>\n      <div className=\"hb-xb2-txt\" aria-live=\"polite\">\n        <div className=\"hb-xb2-t\" data-on={state === \"idle\" ? \"true\" : \"false\"}>\n          <span className=\"hb-xb2-l\">{label}</span>\n          <span className=\"hb-xb2-h\">\n            {hint}\n            <span className=\"hb-xb2-kbd\">Space</span>\n          </span>\n        </div>\n        <div className=\"hb-xb2-t\" data-on={state === \"holding\" ? \"true\" : \"false\"} aria-hidden={state !== \"holding\"}>\n          <span className=\"hb-xb2-l\">{holdingLabel}</span>\n          <span className=\"hb-xb2-h\">{remain.toFixed(1)}s</span>\n        </div>\n        <div className=\"hb-xb2-t\" data-on={state === \"fired\" ? \"true\" : \"false\"} aria-hidden={state !== \"fired\"}>\n          <span className=\"hb-xb2-l\">{firedLabel}</span>\n          <span className=\"hb-xb2-h\">\n            <span className=\"hb-xb2-live\" />\n            {firedHint}\n          </span>\n        </div>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}