{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "like-bookmark",
  "type": "registry:component",
  "title": "Like Bookmark",
  "description": "A bookmark ribbon that drops into a tray with a bounce and a squash, next to a rolling saved counter.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "social",
    "bookmark",
    "save",
    "tray",
    "counter",
    "reading list",
    "toggle"
  ],
  "docs": "https://hyperblur.dev/effects/like-bookmark",
  "files": [
    {
      "path": "registry/hyperblur/like-bookmark.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/like-bookmark.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LikeBookmarkProps extends React.HTMLAttributes<HTMLSpanElement> {\n  count?: number;\n  saved?: boolean;\n  defaultSaved?: boolean;\n  onSavedChange?: (saved: boolean, count: number) => void;\n  color?: string;\n  size?: number;\n  label?: string;\n  noun?: string;\n}\n\nconst css = `\n.hb-qb5 {\n  position: relative;\n  display: inline-flex;\n  vertical-align: middle;\n  box-sizing: border-box;\n  font-family: inherit;\n}\n.hb-qb5 *, .hb-qb5 *::before, .hb-qb5 *::after { box-sizing: border-box; }\n.hb-qb5-btn {\n  --hb-qb5-bg: #171717;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: calc(var(--hb-qb5-s) * 0.36);\n  margin: 0;\n  padding: calc(var(--hb-qb5-s) * 0.26) calc(var(--hb-qb5-s) * 0.7) calc(var(--hb-qb5-s) * 0.26) calc(var(--hb-qb5-s) * 0.5);\n  border: 1px solid #262626;\n  border-radius: calc(var(--hb-qb5-s) * 0.6);\n  background: var(--hb-qb5-bg);\n  color: #8f8f8f;\n  font: inherit;\n  font-size: calc(var(--hb-qb5-s) * 0.58);\n  font-weight: 600;\n  line-height: 1;\n  white-space: nowrap;\n  cursor: pointer;\n  user-select: none;\n  touch-action: manipulation;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease, transform 0.12s ease;\n}\n.hb-qb5-btn:hover { border-color: #3a3a3a; color: #ededed; }\n.hb-qb5-btn:active { transform: scale(0.96); }\n.hb-qb5-btn:focus-visible { outline: 2px solid var(--hb-qb5-c); outline-offset: 3px; }\n.hb-qb5-btn[aria-pressed=\"true\"] {\n  --hb-qb5-bg: color-mix(in srgb, var(--hb-qb5-c) 9%, #171717);\n  border-color: color-mix(in srgb, var(--hb-qb5-c) 45%, #262626);\n  color: #ededed;\n}\n.hb-qb5-ico {\n  display: inline-flex;\n  width: var(--hb-qb5-s);\n  height: calc(var(--hb-qb5-s) * 1.25);\n  flex: none;\n}\n.hb-qb5-ico svg {\n  display: block;\n  width: 100%;\n  height: 100%;\n  overflow: visible;\n  stroke: currentColor;\n  stroke-width: 1.7;\n  stroke-linejoin: round;\n  stroke-linecap: round;\n}\n.hb-qb5-rib {\n  fill: transparent;\n  transform: translateY(0);\n  transition: fill 0.25s ease, stroke 0.25s ease;\n}\n.hb-qb5-btn[aria-pressed=\"true\"] .hb-qb5-rib {\n  fill: var(--hb-qb5-c);\n  stroke: var(--hb-qb5-c);\n  transform: translateY(8.5px);\n}\n.hb-qb5-rib[data-fx=\"save\"] { animation: hb-qb5-drop 0.8s cubic-bezier(0.35, 0.7, 0.4, 1); }\n.hb-qb5-rib[data-fx=\"lift\"] { animation: hb-qb5-lift 0.4s ease-out; }\n@keyframes hb-qb5-drop {\n  0% { transform: translateY(0); }\n  50% { transform: translateY(12px); }\n  68% { transform: translateY(7px); }\n  84% { transform: translateY(9.4px); }\n  100% { transform: translateY(8.5px); }\n}\n@keyframes hb-qb5-lift {\n  0% { transform: translateY(8.5px); }\n  45% { transform: translateY(-2px); }\n  100% { transform: translateY(0); }\n}\n.hb-qb5-tray {\n  fill: var(--hb-qb5-bg);\n  transform-box: fill-box;\n  transform-origin: 50% 100%;\n  transition: fill 0.2s ease, stroke 0.25s ease;\n}\n.hb-qb5-btn[aria-pressed=\"true\"] .hb-qb5-tray { stroke: var(--hb-qb5-c); }\n.hb-qb5-tray[data-fx=\"save\"] { animation: hb-qb5-squash 0.8s ease-out; }\n@keyframes hb-qb5-squash {\n  0%, 44% { transform: scale(1, 1); }\n  54% { transform: scale(1.06, 0.88); }\n  72% { transform: scale(0.98, 1.04); }\n  100% { transform: scale(1, 1); }\n}\n.hb-qb5-count {\n  display: inline-flex;\n  font-variant-numeric: tabular-nums;\n  white-space: pre;\n}\n.hb-qb5-roll {\n  display: inline-grid;\n  overflow: hidden;\n  line-height: 1.25;\n  margin: -0.125em 0;\n}\n.hb-qb5-roll > span { grid-area: 1 / 1; display: block; }\n.hb-qb5-in { animation: hb-qb5-up-in 0.38s cubic-bezier(0.3, 1.3, 0.5, 1) both; }\n.hb-qb5-out { animation: hb-qb5-up-out 0.3s ease-in both; }\n.hb-qb5-roll[data-up=\"false\"] .hb-qb5-in { animation-name: hb-qb5-down-in; }\n.hb-qb5-roll[data-up=\"false\"] .hb-qb5-out { animation-name: hb-qb5-down-out; }\n@keyframes hb-qb5-up-in {\n  from { transform: translateY(100%); opacity: 0; }\n  to { transform: translateY(0); opacity: 1; }\n}\n@keyframes hb-qb5-up-out {\n  from { transform: translateY(0); opacity: 1; }\n  to { transform: translateY(-100%); opacity: 0; }\n}\n@keyframes hb-qb5-down-in {\n  from { transform: translateY(-100%); opacity: 0; }\n  to { transform: translateY(0); opacity: 1; }\n}\n@keyframes hb-qb5-down-out {\n  from { transform: translateY(0); opacity: 1; }\n  to { transform: translateY(100%); opacity: 0; }\n}\n.hb-qb5-noun { margin-left: -0.15em; color: #8f8f8f; font-weight: 500; }\n.hb-qb5-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-qb5-btn, .hb-qb5-rib, .hb-qb5-tray { transition: none; }\n  .hb-qb5-rib[data-fx], .hb-qb5-tray[data-fx] { animation: none; }\n  .hb-qb5-out { display: none; }\n  .hb-qb5-in { animation: none; }\n}\n`;\n\nconst ribbon = \"M8 -3h8a1 1 0 011 1v14l-5-3.6L7 12V-2a1 1 0 011-1z\";\nconst tray = \"M2.5 19.5h19v2.4a2.8 2.8 0 01-2.8 2.8H5.3a2.8 2.8 0 01-2.8-2.8z\";\n\ninterface RollState {\n  value: number;\n  prev: number;\n  id: number;\n  live: boolean;\n}\n\nfunction Roll({ value }: { value: number }) {\n  const [view, setView] = React.useState<RollState>({ value, prev: value, id: 0, live: false });\n  if (view.value !== value) {\n    setView({ value, prev: view.value, id: view.id + 1, live: true });\n  }\n  const to = value.toLocaleString(\"en-US\");\n  if (!view.live) {\n    return (\n      <span className=\"hb-qb5-count\" aria-hidden=\"true\">\n        {to}\n      </span>\n    );\n  }\n  const from = view.prev.toLocaleString(\"en-US\");\n  let p = 0;\n  while (p < from.length && p < to.length && from[p] === to[p]) p++;\n  return (\n    <span className=\"hb-qb5-count\" aria-hidden=\"true\">\n      {to.slice(0, p)}\n      <span key={view.id} className=\"hb-qb5-roll\" data-up={value > view.prev ? \"true\" : \"false\"}>\n        <span className=\"hb-qb5-out\">{from.slice(p)}</span>\n        <span\n          className=\"hb-qb5-in\"\n          onAnimationEnd={() => setView((v) => (v.live ? { ...v, live: false } : v))}\n        >\n          {to.slice(p)}\n        </span>\n      </span>\n    </span>\n  );\n}\n\nexport function LikeBookmark({\n  count = 0,\n  saved,\n  defaultSaved = false,\n  onSavedChange,\n  color = \"#7fb3ff\",\n  size = 22,\n  label = \"Save\",\n  noun = \"saved\",\n  className = \"\",\n  style,\n  ...rest\n}: LikeBookmarkProps) {\n  const controlled = saved !== undefined;\n  const [inner, setInner] = React.useState(defaultSaved);\n  const current = controlled ? saved : inner;\n  const [base] = React.useState(current);\n  const [seen, setSeen] = React.useState({ saved: current, pulse: 0 });\n\n  if (seen.saved !== current) {\n    setSeen({ saved: current, pulse: seen.pulse + 1 });\n  }\n\n  const offset = current === base ? 0 : current ? 1 : -1;\n  const total = Math.max(0, count + offset);\n  const fx = seen.pulse === 0 ? undefined : current ? \"save\" : \"lift\";\n\n  function toggle() {\n    const next = !current;\n    if (!controlled) setInner(next);\n    const nextOffset = next === base ? 0 : next ? 1 : -1;\n    onSavedChange?.(next, Math.max(0, count + nextOffset));\n  }\n\n  const vars = {\n    \"--hb-qb5-s\": `${size}px`,\n    \"--hb-qb5-c\": color,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <span className={`hb-qb5 ${className}`} style={vars} {...rest}>\n      <style href=\"hb-like-bookmark\" precedence=\"default\">{css}</style>\n      <button type=\"button\" className=\"hb-qb5-btn\" aria-pressed={current} aria-label={label} onClick={toggle}>\n        <span className=\"hb-qb5-ico\" aria-hidden=\"true\">\n          <svg viewBox=\"0 -4 24 30\">\n            <path key={`r${seen.pulse}`} className=\"hb-qb5-rib\" data-fx={fx} d={ribbon} />\n            <path key={`t${seen.pulse}`} className=\"hb-qb5-tray\" data-fx={fx} d={tray} />\n          </svg>\n        </span>\n        <Roll value={total} />\n        {noun && (\n          <span className=\"hb-qb5-noun\" aria-hidden=\"true\">\n            {noun}\n          </span>\n        )}\n      </button>\n      <span className=\"hb-qb5-sr\" role=\"status\" aria-live=\"polite\">\n        {`${total.toLocaleString(\"en-US\")} ${noun || \"saves\"}`}\n      </span>\n    </span>\n  );\n}\n"
    }
  ]
}