{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-check-draw",
  "type": "registry:component",
  "title": "Button Check Draw",
  "description": "The button folds into a circle, a ring spins while the action runs, then closes, fills and draws a checkmark before opening back up with the result. Accepts an async handler.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "confirm",
    "checkmark",
    "loading",
    "async",
    "morph"
  ],
  "docs": "https://hyperblur.dev/effects/button-check-draw",
  "files": [
    {
      "path": "registry/hyperblur/button-check-draw.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-check-draw.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonCheckDrawProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"children\" | \"onClick\" | \"color\"> {\n  children?: React.ReactNode;\n  doneLabel?: React.ReactNode;\n  minDuration?: number;\n  accent?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  resetAfter?: number;\n  onConfirm?: () => void | Promise<unknown>;\n}\n\nconst css = `\n.hb-xd7 {\n  --hb-xd7-h: 2.75rem;\n  --hb-xd7-fs: 0.875rem;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  box-sizing: border-box;\n  min-width: var(--hb-xd7-h);\n  height: var(--hb-xd7-h);\n  margin: 0;\n  padding: 0 1.3em;\n  font-family: inherit;\n  font-size: var(--hb-xd7-fs);\n  font-weight: 600;\n  letter-spacing: -0.005em;\n  color: #fff;\n  white-space: nowrap;\n  border: 1px solid color-mix(in srgb, var(--hb-xd7-c) 70%, #000);\n  border-radius: 999px;\n  background:\n    linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0) 55%),\n    linear-gradient(180deg, color-mix(in srgb, var(--hb-xd7-c) 95%, #fff), color-mix(in srgb, var(--hb-xd7-c) 88%, #000));\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.5), 0 10px 26px -12px var(--hb-xd7-c);\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  transition:\n    padding 0.5s cubic-bezier(0.7, 0, 0.2, 1),\n    background 0.4s ease,\n    border-color 0.4s ease,\n    box-shadow 0.4s ease,\n    transform 0.2s cubic-bezier(0.3, 1.5, 0.5, 1);\n}\n.hb-xd7 *, .hb-xd7 *::before, .hb-xd7 *::after { box-sizing: border-box; }\n.hb-xd7[data-size=\"sm\"] { --hb-xd7-h: 2.25rem; --hb-xd7-fs: 0.8125rem; }\n.hb-xd7[data-size=\"lg\"] { --hb-xd7-h: 3.25rem; --hb-xd7-fs: 1rem; }\n.hb-xd7:hover:not(:disabled)[data-phase=\"idle\"] { box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.5), 0 12px 30px -10px var(--hb-xd7-c); }\n.hb-xd7:active:not(:disabled)[data-phase=\"idle\"] { transform: scale(0.97); }\n.hb-xd7:focus-visible { outline: 2px solid color-mix(in srgb, var(--hb-xd7-c) 65%, #fff); outline-offset: 3px; }\n.hb-xd7:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-xd7-wrap {\n  display: grid;\n  grid-template-columns: 1fr;\n  transition: grid-template-columns 0.5s cubic-bezier(0.7, 0, 0.2, 1), opacity 0.25s ease;\n}\n.hb-xd7-inner { display: flex; align-items: center; gap: 0.5em; min-width: 0; overflow: hidden; }\n.hb-xd7-inner > span { display: inline-flex; align-items: center; gap: 0.5em; }\n.hb-xd7[data-phase=\"busy\"], .hb-xd7[data-phase=\"check\"] {\n  padding: 0;\n  cursor: progress;\n  background: #141414;\n  border-color: #2a2a2a;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 1px 2px rgba(0,0,0,0.5);\n}\n.hb-xd7[data-phase=\"busy\"] .hb-xd7-wrap, .hb-xd7[data-phase=\"check\"] .hb-xd7-wrap { grid-template-columns: 0fr; opacity: 0; }\n.hb-xd7-svg {\n  position: absolute;\n  inset: -1px;\n  width: calc(100% + 2px);\n  height: calc(100% + 2px);\n  overflow: visible;\n  pointer-events: none;\n  opacity: 0;\n  transition: opacity 0.2s ease;\n}\n.hb-xd7[data-phase=\"busy\"] .hb-xd7-svg, .hb-xd7[data-phase=\"check\"] .hb-xd7-svg { opacity: 1; transition-delay: 0.4s; }\n.hb-xd7-ring {\n  fill: none;\n  stroke: var(--hb-xd7-c);\n  stroke-width: 2.2;\n  stroke-linecap: round;\n  stroke-dasharray: 25 100;\n  transform-origin: 50% 50%;\n  transform-box: fill-box;\n}\n.hb-xd7[data-phase=\"busy\"] .hb-xd7-ring { animation: hb-xd7-spin 0.9s cubic-bezier(0.5, 0.15, 0.5, 0.85) infinite; }\n.hb-xd7[data-phase=\"check\"] .hb-xd7-ring { stroke-dasharray: 100 100; transition: stroke-dasharray 0.35s cubic-bezier(0.3, 0.9, 0.3, 1); }\n.hb-xd7-disc {\n  fill: var(--hb-xd7-c);\n  transform-origin: 50% 50%;\n  transform-box: fill-box;\n  transform: scale(0);\n}\n.hb-xd7[data-phase=\"check\"] .hb-xd7-disc { animation: hb-xd7-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 0.2s forwards; }\n.hb-xd7-tick {\n  fill: none;\n  stroke: #fff;\n  stroke-width: 2.6;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n  stroke-dasharray: 20;\n  stroke-dashoffset: 20;\n}\n.hb-xd7[data-phase=\"check\"] .hb-xd7-tick { animation: hb-xd7-draw 0.35s cubic-bezier(0.6, 0, 0.3, 1) 0.45s forwards; }\n.hb-xd7[data-phase=\"done\"] {\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xd7-c) 16%, #161616), color-mix(in srgb, var(--hb-xd7-c) 8%, #111));\n  border-color: color-mix(in srgb, var(--hb-xd7-c) 40%, #262626);\n  color: color-mix(in srgb, var(--hb-xd7-c) 40%, #fff);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);\n  cursor: default;\n}\n.hb-xd7[data-phase=\"done\"] .hb-xd7-inner > span { animation: hb-xd7-in 0.4s cubic-bezier(0.2, 1.2, 0.4, 1); }\n.hb-xd7-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-xd7-spin { to { transform: rotate(360deg); } }\n@keyframes hb-xd7-pop { to { transform: scale(1); } }\n@keyframes hb-xd7-draw { to { stroke-dashoffset: 0; } }\n@keyframes hb-xd7-in { from { opacity: 0; transform: translateY(5px); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xd7, .hb-xd7-wrap, .hb-xd7-svg, .hb-xd7-ring { transition: none; }\n  .hb-xd7[data-phase=\"busy\"] .hb-xd7-ring, .hb-xd7[data-phase=\"done\"] .hb-xd7-inner > span { animation: none; }\n  .hb-xd7[data-phase=\"check\"] .hb-xd7-disc { animation: none; transform: scale(1); }\n  .hb-xd7[data-phase=\"check\"] .hb-xd7-tick { animation: none; stroke-dashoffset: 0; }\n}\n`;\n\nexport function ButtonCheckDraw({\n  children = \"Remove member\",\n  doneLabel = \"Removed\",\n  minDuration = 1100,\n  accent = \"#e5484d\",\n  size = \"md\",\n  resetAfter = 2400,\n  onConfirm,\n  disabled = false,\n  type = \"button\",\n  className = \"\",\n  style,\n  ...rest\n}: ButtonCheckDrawProps) {\n  const [phase, setPhase] = React.useState<\"idle\" | \"busy\" | \"check\" | \"done\">(\"idle\");\n  const latest = React.useRef(onConfirm);\n  const alive = React.useRef(true);\n\n  React.useEffect(() => {\n    latest.current = onConfirm;\n  }, [onConfirm]);\n\n  React.useEffect(() => {\n    alive.current = true;\n    return () => {\n      alive.current = false;\n    };\n  }, []);\n\n  React.useEffect(() => {\n    if (phase === \"check\") {\n      const t = window.setTimeout(() => setPhase(\"done\"), 1100);\n      return () => window.clearTimeout(t);\n    }\n    if (phase === \"done\" && resetAfter > 0) {\n      const t = window.setTimeout(() => setPhase(\"idle\"), resetAfter);\n      return () => window.clearTimeout(t);\n    }\n  }, [phase, resetAfter]);\n\n  const run = async () => {\n    if (phase !== \"idle\" || disabled) return;\n    setPhase(\"busy\");\n    const wait = new Promise((r) => window.setTimeout(r, minDuration));\n    try {\n      await Promise.all([Promise.resolve(latest.current?.()), wait]);\n      if (alive.current) setPhase(\"check\");\n    } catch {\n      if (alive.current) setPhase(\"idle\");\n    }\n  };\n\n  return (\n    <button\n      type={type}\n      className={`hb-xd7 ${className}`.trim()}\n      data-size={size}\n      data-phase={phase}\n      disabled={disabled}\n      aria-busy={phase === \"busy\" || undefined}\n      aria-disabled={phase !== \"idle\" || undefined}\n      style={{ \"--hb-xd7-c\": accent, ...style } as React.CSSProperties}\n      onClick={run}\n      {...rest}\n    >\n      <style href=\"hb-button-check-draw\" precedence=\"default\">{css}</style>\n      <span className=\"hb-xd7-wrap\">\n        <span className=\"hb-xd7-inner\">\n          {phase === \"done\" ? (\n            <span>\n              <svg viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n              {doneLabel}\n            </span>\n          ) : (\n            <span>\n              <svg viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                <circle cx=\"10\" cy=\"8\" r=\"4\" />\n                <path d=\"M3 20c.8-3.6 3.6-5.5 7-5.5 1.6 0 3 .4 4.2 1.2\" />\n                <path d=\"M16 18h6\" />\n              </svg>\n              {children}\n            </span>\n          )}\n        </span>\n      </span>\n      <svg className=\"hb-xd7-svg\" viewBox=\"0 0 44 44\" aria-hidden=\"true\">\n        <circle className=\"hb-xd7-disc\" cx=\"22\" cy=\"22\" r=\"17\" />\n        <circle className=\"hb-xd7-ring\" cx=\"22\" cy=\"22\" r=\"21\" pathLength={100} />\n        <path className=\"hb-xd7-tick\" d=\"M15 22.5l4.6 4.6L29.5 17\" pathLength={20} />\n      </svg>\n      <span className=\"hb-xd7-sr\" role=\"status\" aria-live=\"polite\">{phase === \"busy\" ? \"Working\" : phase === \"done\" ? doneLabel : \"\"}</span>\n    </button>\n  );\n}\n"
    }
  ]
}