{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-archive-discard",
  "type": "registry:component",
  "title": "Button Archive Discard",
  "description": "A paired control where the hovered side stretches and the other shrinks to its icon. Archive drops a page into a box, Discard crushes its cross into a checkmark and takes the full width.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button group",
    "archive",
    "discard",
    "split",
    "email",
    "choice"
  ],
  "docs": "https://hyperblur.dev/effects/button-archive-discard",
  "files": [
    {
      "path": "registry/hyperblur/button-archive-discard.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-archive-discard.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonArchiveDiscardProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  archiveLabel?: string;\n  discardLabel?: string;\n  archivedLabel?: string;\n  discardedLabel?: string;\n  accent?: string;\n  archiveAccent?: string;\n  resetAfter?: number;\n  disabled?: boolean;\n  onArchive?: () => void;\n  onDiscard?: () => void;\n}\n\nconst css = `\n.hb-xd10 {\n  display: flex;\n  gap: 4px;\n  box-sizing: border-box;\n  width: 100%;\n  max-width: 300px;\n  padding: 4px;\n  font-family: inherit;\n  font-size: 0.8125rem;\n  border-radius: 14px;\n  background: linear-gradient(180deg, #0b0b0b, #111);\n  border: 1px solid #222;\n  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04);\n}\n.hb-xd10 *, .hb-xd10 *::before, .hb-xd10 *::after { box-sizing: border-box; }\n.hb-xd10[data-disabled=\"true\"] { opacity: 0.45; }\n.hb-xd10-btn {\n  --hb-xd10-k: #a1a1a1;\n  position: relative;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  flex: 1 1 0;\n  min-width: 40px;\n  height: 2.5rem;\n  margin: 0;\n  padding: 0 10px;\n  overflow: hidden;\n  font: inherit;\n  font-weight: 600;\n  color: #d4d4d4;\n  white-space: nowrap;\n  background: linear-gradient(180deg, #1c1c1c, #151515);\n  border: 1px solid #2a2a2a;\n  border-radius: 10px;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 1px 2px rgba(0,0,0,0.4);\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  isolation: isolate;\n  transition: flex-grow 0.55s cubic-bezier(0.3, 1.3, 0.4, 1), min-width 0.45s cubic-bezier(0.6, 0, 0.2, 1), padding 0.45s ease, color 0.25s ease, border-color 0.25s ease, opacity 0.3s ease, transform 0.15s ease;\n}\n.hb-xd10-btn:active:not(:disabled) { transform: scale(0.97); }\n.hb-xd10-btn:focus-visible { outline: 2px solid var(--hb-xd10-k); outline-offset: 2px; }\n.hb-xd10-btn:disabled { cursor: not-allowed; }\n.hb-xd10-a { --hb-xd10-k: var(--hb-xd10-ac); }\n.hb-xd10-d { --hb-xd10-k: var(--hb-xd10-c); }\n.hb-xd10-btn::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--hb-xd10-k) 30%, transparent), color-mix(in srgb, var(--hb-xd10-k) 12%, transparent) 70%);\n  opacity: 0;\n  transform: scale(0.4);\n  border-radius: inherit;\n  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.2, 1, 0.3, 1);\n}\n.hb-xd10-btn[data-hot=\"true\"] { flex-grow: 2.4; color: #fff; border-color: color-mix(in srgb, var(--hb-xd10-k) 45%, #2a2a2a); }\n.hb-xd10-btn[data-hot=\"true\"]::before { opacity: 1; transform: scale(1); }\n.hb-xd10-lbl {\n  display: inline-block;\n  max-width: 9em;\n  margin-left: 0.5em;\n  overflow: hidden;\n  text-overflow: clip;\n  transition: max-width 0.45s cubic-bezier(0.6, 0, 0.2, 1), margin 0.45s ease, opacity 0.25s ease;\n}\n.hb-xd10-btn[data-cold=\"true\"] .hb-xd10-lbl { max-width: 0; margin-left: 0; opacity: 0; }\n.hb-xd10-btn[data-gone=\"true\"] { flex-grow: 0; min-width: 0; padding: 0; border-width: 0; opacity: 0; pointer-events: none; }\n.hb-xd10[data-result] { gap: 0; }\n.hb-xd10-btn[data-picked=\"true\"] { flex-grow: 1; color: #fff; border-color: color-mix(in srgb, var(--hb-xd10-k) 55%, #2a2a2a); cursor: default; }\n.hb-xd10-btn[data-picked=\"true\"]::before { opacity: 1; transform: scale(1.6); }\n.hb-xd10-ic { flex: none; width: 17px; height: 17px; overflow: visible; color: var(--hb-xd10-k); }\n.hb-xd10-boxlid { transform-box: fill-box; transform-origin: 50% 100%; transition: transform 0.45s cubic-bezier(0.3, 1.8, 0.5, 1); }\n.hb-xd10-a[data-hot=\"true\"] .hb-xd10-boxlid { transform: translateY(-3px) rotate(-6deg); }\n.hb-xd10-a[data-picked=\"true\"] .hb-xd10-boxlid { animation: hb-xd10-shut 0.6s cubic-bezier(0.3, 1.4, 0.5, 1); }\n.hb-xd10-docin { opacity: 0; transform-box: fill-box; }\n.hb-xd10-a[data-picked=\"true\"] .hb-xd10-docin { animation: hb-xd10-doc 0.6s cubic-bezier(0.5, 0, 0.7, 0.4); }\n.hb-xd10-x { transform-box: fill-box; transform-origin: 50% 50%; transition: transform 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }\n.hb-xd10-d[data-hot=\"true\"] .hb-xd10-x { transform: rotate(90deg) scale(1.08); }\n.hb-xd10-d[data-picked=\"true\"] .hb-xd10-x { animation: hb-xd10-crush 0.5s cubic-bezier(0.5, 0, 0.3, 1) forwards; }\n.hb-xd10-chk { stroke-dasharray: 20; stroke-dashoffset: 20; }\n.hb-xd10-btn[data-picked=\"true\"] .hb-xd10-chk { animation: hb-xd10-draw 0.35s ease 0.4s forwards; }\n.hb-xd10-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-xd10-shut {\n  0% { transform: translateY(-6px) rotate(-10deg); }\n  60% { transform: translateY(0.5px) rotate(2deg); }\n  100% { transform: none; }\n}\n@keyframes hb-xd10-doc {\n  0% { opacity: 1; transform: translateY(-9px); }\n  70% { opacity: 1; transform: translateY(3px); }\n  100% { opacity: 0; transform: translateY(4px); }\n}\n@keyframes hb-xd10-crush { to { transform: rotate(180deg) scale(0); opacity: 0; } }\n@keyframes hb-xd10-draw { to { stroke-dashoffset: 0; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xd10-btn, .hb-xd10-btn::before, .hb-xd10-lbl, .hb-xd10-boxlid, .hb-xd10-x { transition: none; }\n  .hb-xd10-btn[data-picked=\"true\"] .hb-xd10-boxlid, .hb-xd10-btn[data-picked=\"true\"] .hb-xd10-docin { animation: none; }\n  .hb-xd10-d[data-picked=\"true\"] .hb-xd10-x { animation: none; opacity: 0; }\n  .hb-xd10-btn[data-picked=\"true\"] .hb-xd10-chk { animation: none; stroke-dashoffset: 0; }\n}\n`;\n\ntype Choice = \"archive\" | \"discard\";\n\nexport function ButtonArchiveDiscard({\n  archiveLabel = \"Archive\",\n  discardLabel = \"Discard\",\n  archivedLabel = \"Archived to Done\",\n  discardedLabel = \"Draft discarded\",\n  accent = \"#ef4444\",\n  archiveAccent = \"#a1a1a1\",\n  resetAfter = 2400,\n  disabled = false,\n  onArchive,\n  onDiscard,\n  className = \"\",\n  style,\n  ...rest\n}: ButtonArchiveDiscardProps) {\n  const [hot, setHot] = React.useState<Choice | null>(null);\n  const [result, setResult] = React.useState<Choice | null>(null);\n  const refs = React.useRef<Record<Choice, HTMLButtonElement | null>>({ archive: null, discard: null });\n  const latest = React.useRef({ onArchive, onDiscard });\n\n  React.useEffect(() => {\n    latest.current = { onArchive, onDiscard };\n  }, [onArchive, onDiscard]);\n\n  React.useEffect(() => {\n    if (!result || resetAfter <= 0) return;\n    const t = window.setTimeout(() => {\n      setResult(null);\n      setHot(null);\n    }, resetAfter);\n    return () => window.clearTimeout(t);\n  }, [result, resetAfter]);\n\n  const pick = (c: Choice) => {\n    if (disabled || result) return;\n    setResult(c);\n    if (c === \"archive\") latest.current.onArchive?.();\n    else latest.current.onDiscard?.();\n  };\n\n  const attrs = (c: Choice) => ({\n    \"data-hot\": !result && hot === c,\n    \"data-cold\": !result && hot !== null && hot !== c,\n    \"data-picked\": result === c,\n    \"data-gone\": result !== null && result !== c,\n  });\n\n  const keys = (e: React.KeyboardEvent, c: Choice) => {\n    if (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\") {\n      e.preventDefault();\n      refs.current[c === \"archive\" ? \"discard\" : \"archive\"]?.focus();\n    }\n  };\n\n  return (\n    <div\n      role=\"group\"\n      aria-label=\"Archive or discard\"\n      className={`hb-xd10 ${className}`.trim()}\n      data-result={result ?? undefined}\n      data-disabled={disabled}\n      style={{ \"--hb-xd10-c\": accent, \"--hb-xd10-ac\": archiveAccent, ...style } as React.CSSProperties}\n      onPointerLeave={() => setHot(null)}\n      {...rest}\n    >\n      <style href=\"hb-button-archive-discard\" precedence=\"default\">{css}</style>\n      <button\n        ref={(el) => {\n          refs.current.archive = el;\n        }}\n        type=\"button\"\n        className=\"hb-xd10-btn hb-xd10-a\"\n        disabled={disabled}\n        tabIndex={result === \"discard\" ? -1 : 0}\n        aria-hidden={result === \"discard\" || undefined}\n        onPointerEnter={() => setHot(\"archive\")}\n        onFocus={() => setHot(\"archive\")}\n        onBlur={() => setHot(null)}\n        onKeyDown={(e) => keys(e, \"archive\")}\n        onClick={() => pick(\"archive\")}\n        {...attrs(\"archive\")}\n      >\n        <svg className=\"hb-xd10-ic\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n          <rect className=\"hb-xd10-docin\" x=\"9\" y=\"4\" width=\"6\" height=\"6\" rx=\"1\" />\n          <path className=\"hb-xd10-boxlid\" d=\"M3 5.5h18v3.5H3z\" />\n          <path d=\"M5 9v9.5c0 .8.7 1.5 1.5 1.5h11c.8 0 1.5-.7 1.5-1.5V9\" />\n          <path d=\"M10 13h4\" />\n        </svg>\n        <span className=\"hb-xd10-lbl\">{result === \"archive\" ? archivedLabel : archiveLabel}</span>\n      </button>\n      <button\n        ref={(el) => {\n          refs.current.discard = el;\n        }}\n        type=\"button\"\n        className=\"hb-xd10-btn hb-xd10-d\"\n        disabled={disabled}\n        tabIndex={result === \"archive\" ? -1 : 0}\n        aria-hidden={result === \"archive\" || undefined}\n        onPointerEnter={() => setHot(\"discard\")}\n        onFocus={() => setHot(\"discard\")}\n        onBlur={() => setHot(null)}\n        onKeyDown={(e) => keys(e, \"discard\")}\n        onClick={() => pick(\"discard\")}\n        {...attrs(\"discard\")}\n      >\n        <svg className=\"hb-xd10-ic\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n          <g className=\"hb-xd10-x\">\n            <path d=\"M7 7l10 10M17 7L7 17\" />\n          </g>\n          {result === \"discard\" && <path className=\"hb-xd10-chk\" d=\"M5 12.5l4.5 4.5L19 7.5\" pathLength={20} />}\n        </svg>\n        <span className=\"hb-xd10-lbl\">{result === \"discard\" ? discardedLabel : discardLabel}</span>\n      </button>\n      <span className=\"hb-xd10-sr\" role=\"status\" aria-live=\"polite\">\n        {result === \"archive\" ? archivedLabel : result === \"discard\" ? discardedLabel : \"\"}\n      </span>\n    </div>\n  );\n}\n"
    }
  ]
}