{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-slide-fill",
  "type": "registry:component",
  "title": "Button Slide Fill",
  "description": "Color fills from the side the pointer enters and drains out through the side it leaves, with the label color inverting in sync.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "fill",
    "slide",
    "hover",
    "direction",
    "invert"
  ],
  "docs": "https://hyperblur.dev/effects/button-slide-fill",
  "files": [
    {
      "path": "registry/hyperblur/button-slide-fill.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-slide-fill.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonSlideFillProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"color\"> {\n  variant?: \"outline\" | \"solid\";\n  accent?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  loading?: boolean;\n  idle?: boolean;\n}\n\ntype Side = \"left\" | \"right\" | \"top\" | \"bottom\";\n\nconst css = `\n.hb-qa2 {\n  --hb-qa2-c: #2f7bff;\n  --hb-qa2-bg: transparent;\n  --hb-qa2-fg: #ededed;\n  --hb-qa2-fill: #ededed;\n  --hb-qa2-ink: #0a0a0a;\n  --hb-qa2-ring: #333333;\n  --hb-qa2-closed: inset(0 100% 0 0);\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  box-sizing: border-box;\n  margin: 0;\n  padding: 0.8em 1.6em;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 600;\n  line-height: 1.2;\n  color: var(--hb-qa2-fg);\n  background: var(--hb-qa2-bg);\n  border: 0;\n  border-radius: 10px;\n  box-shadow: inset 0 0 0 1px var(--hb-qa2-ring);\n  cursor: pointer;\n  overflow: hidden;\n  isolation: isolate;\n  user-select: none;\n  -webkit-tap-highlight-color: transparent;\n  touch-action: manipulation;\n  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);\n}\n.hb-qa2[data-size=\"sm\"] { font-size: 13px; }\n.hb-qa2[data-size=\"lg\"] { font-size: 17px; }\n.hb-qa2[data-variant=\"solid\"] {\n  --hb-qa2-bg: var(--hb-qa2-c);\n  --hb-qa2-fg: #ffffff;\n  --hb-qa2-fill: #ffffff;\n  --hb-qa2-ink: #0a0a0a;\n  --hb-qa2-ring: transparent;\n}\n.hb-qa2[data-side=\"left\"] { --hb-qa2-closed: inset(0 100% 0 0); }\n.hb-qa2[data-side=\"right\"] { --hb-qa2-closed: inset(0 0 0 100%); }\n.hb-qa2[data-side=\"top\"] { --hb-qa2-closed: inset(0 0 100% 0); }\n.hb-qa2[data-side=\"bottom\"] { --hb-qa2-closed: inset(100% 0 0 0); }\n.hb-qa2-t, .hb-qa2-o {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 0.6em;\n  white-space: nowrap;\n}\n.hb-qa2-o {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  color: var(--hb-qa2-ink);\n  background: var(--hb-qa2-fill);\n  clip-path: var(--hb-qa2-closed);\n  transition: clip-path 0.42s cubic-bezier(0.65, 0, 0.25, 1);\n  pointer-events: none;\n}\n.hb-qa2[data-snap=\"true\"] .hb-qa2-o { transition: none; }\n.hb-qa2[data-active=\"true\"] .hb-qa2-o { clip-path: inset(0 0 0 0); }\n.hb-qa2[data-idle=\"true\"][data-active=\"false\"] .hb-qa2-o {\n  animation: hb-qa2-sweep 4.8s cubic-bezier(0.65, 0, 0.25, 1) infinite;\n}\n.hb-qa2:active:not(:disabled) { transform: scale(0.97); }\n.hb-qa2:focus-visible { outline: 2px solid var(--hb-qa2-c); outline-offset: 3px; }\n.hb-qa2:disabled { cursor: not-allowed; }\n.hb-qa2:disabled:not([aria-busy=\"true\"]) { opacity: 0.45; }\n.hb-qa2-sp {\n  width: 1em;\n  height: 1em;\n  flex: none;\n  border: 2px solid currentColor;\n  border-right-color: transparent;\n  border-radius: 50%;\n  animation: hb-qa2-spin 0.7s linear infinite;\n}\n@keyframes hb-qa2-spin { to { transform: rotate(360deg); } }\n@keyframes hb-qa2-sweep {\n  0%, 62% { clip-path: inset(0 100% 0 0); }\n  74%, 80% { clip-path: inset(0 0 0 0); }\n  92%, 100% { clip-path: inset(0 0 0 100%); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qa2, .hb-qa2-o { transition: none; }\n  .hb-qa2[data-idle=\"true\"][data-active=\"false\"] .hb-qa2-o { animation: none; }\n  .hb-qa2:active:not(:disabled) { transform: none; }\n  .hb-qa2-sp { animation-duration: 1.6s; }\n}\n`;\n\nfunction nearestSide(el: HTMLElement, x: number, y: number): Side {\n  const r = el.getBoundingClientRect();\n  const dl = Math.abs(x - r.left);\n  const dr = Math.abs(r.right - x);\n  const dt = Math.abs(y - r.top);\n  const db = Math.abs(r.bottom - y);\n  const m = Math.min(dl, dr, dt, db);\n  if (m === dl) return \"left\";\n  if (m === dr) return \"right\";\n  if (m === dt) return \"top\";\n  return \"bottom\";\n}\n\nexport function ButtonSlideFill({\n  children = \"Join the waitlist\",\n  variant = \"outline\",\n  accent = \"#2f7bff\",\n  size = \"md\",\n  loading = false,\n  disabled = false,\n  idle = true,\n  type = \"button\",\n  className = \"\",\n  style,\n  onPointerEnter,\n  onPointerLeave,\n  onFocus,\n  onBlur,\n  ...rest\n}: ButtonSlideFillProps) {\n  const ref = React.useRef<HTMLButtonElement>(null);\n  const timer = React.useRef(0);\n  const inert = disabled || loading;\n\n  React.useEffect(() => {\n    return () => window.clearTimeout(timer.current);\n  }, []);\n\n  function open(el: HTMLButtonElement, side: Side) {\n    window.clearTimeout(timer.current);\n    el.dataset.idle = \"false\";\n    el.dataset.snap = \"true\";\n    el.dataset.side = side;\n    void el.offsetWidth;\n    el.dataset.snap = \"false\";\n    el.dataset.active = \"true\";\n  }\n\n  function close(el: HTMLButtonElement, side: Side) {\n    el.dataset.side = side;\n    el.dataset.active = \"false\";\n    timer.current = window.setTimeout(() => {\n      el.dataset.idle = idle ? \"true\" : \"false\";\n    }, 1400);\n  }\n\n  const vars = { \"--hb-qa2-c\": accent, ...style } as React.CSSProperties;\n  const label = (\n    <>\n      {loading ? <span className=\"hb-qa2-sp\" aria-hidden=\"true\" /> : null}\n      {children}\n    </>\n  );\n\n  return (\n    <>\n      <style href=\"hb-button-slide-fill\" precedence=\"default\">{css}</style>\n      <button\n        ref={ref}\n        type={type}\n        className={`hb-qa2 ${className}`}\n        style={vars}\n        data-variant={variant}\n        data-size={size}\n        data-side=\"left\"\n        data-active=\"false\"\n        data-idle={idle ? \"true\" : \"false\"}\n        data-snap=\"false\"\n        disabled={inert}\n        aria-busy={loading || undefined}\n        onPointerEnter={(e) => {\n          if (!inert) open(e.currentTarget, nearestSide(e.currentTarget, e.clientX, e.clientY));\n          onPointerEnter?.(e);\n        }}\n        onPointerLeave={(e) => {\n          close(e.currentTarget, nearestSide(e.currentTarget, e.clientX, e.clientY));\n          onPointerLeave?.(e);\n        }}\n        onFocus={(e) => {\n          if (!inert && e.currentTarget.matches(\":focus-visible\")) open(e.currentTarget, \"left\");\n          onFocus?.(e);\n        }}\n        onBlur={(e) => {\n          close(e.currentTarget, \"right\");\n          onBlur?.(e);\n        }}\n        {...rest}\n      >\n        <span className=\"hb-qa2-t\">{label}</span>\n        <span className=\"hb-qa2-o\" aria-hidden=\"true\">{label}</span>\n      </button>\n    </>\n  );\n}\n"
    }
  ]
}