{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "like",
  "type": "registry:component",
  "title": "Like",
  "description": "Press the heart and it pops with a burst while the count rolls up a digit.",
  "author": "Bencho <https://bencho.dev>",
  "dependencies": [
    "framer-motion@^13.1.1",
    "lucide-react@^1.31.0"
  ],
  "registryDependencies": [
    "https://bencho.dev/r/bencho-tokens.json"
  ],
  "files": [
    {
      "path": "registry/bencho/like/Like.tsx",
      "type": "registry:component",
      "target": "@components/bencho/like/Like.tsx",
      "content": "\"use client\";\n\nimport \"./Like.css\";\nimport \"../bencho-tokens.css\";\nimport { useState } from \"react\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport { Heart } from \"lucide-react\";\n\n/* ══ Like ═════════════════════════════════════════════════\n   A heart and a count. Press it and the heart vanishes, a disc\n   blooms where it was and hollows out into a ring, seven pairs\n   of coloured dots burst off the ring, and the heart springs\n   back in red and past its size — while the count rolls up one.\n   Press again and it empties and the count rolls back down.\n\n   ── ONLY THE DIGITS THAT CHANGE ROLL ────────────────────\n   An odometer, not a number being replaced: 1,284 to 1,285\n   turns the last wheel and leaves the rest where they are,\n   and 1,299 to 1,300 turns three, each a beat after the one\n   to its right, the way a carry travels. Every digit is keyed\n   by its place and its value, so a digit that did not change\n   is the same element and never moves.\n\n   ── UP FOR MORE, DOWN FOR LESS ─────────────────────────\n   Liking rolls the new digit in from below and the old one out\n   the top; unliking runs the other way. Direction is the whole\n   difference between a count going up and a count being\n   replaced. */\n\nconst H = 44;\nconst RED = \"#e5484d\";\n/* the confetti: a pair of dots per spoke, never the same colour\n   twice in a pair */\nconst CONFETTI = [\"#f48ea7\", \"#cc8ef5\", \"#8ce8c3\", \"#91d2fa\", \"#f5a524\", \"#e5484d\", \"#9fc7fa\"];\n\nconst clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));\nconst fmt = (n: number) => n.toLocaleString(\"en-US\");\n\nfunction Roll({ value, up }: { value: number; up: boolean }) {\n  const chars = fmt(value).split(\"\");\n  /* places counted from the right, so a new leading digit does\n     not shift the keys of the ones already there */\n  return (\n    <span className=\"lk-count\" aria-hidden=\"true\">\n      {chars.map((c, i) => {\n        const place = chars.length - 1 - i;\n        if (c === \",\") return <span key={`c${place}`} className=\"lk-comma\">,</span>;\n        return (\n          <span key={`p${place}`} className=\"lk-wheel\">\n            <AnimatePresence initial={false} mode=\"popLayout\">\n              <motion.span\n                key={c}\n                className=\"lk-digit\"\n                initial={{ y: up ? \"100%\" : \"-100%\", opacity: 0 }}\n                animate={{ y: \"0%\", opacity: 1 }}\n                exit={{ y: up ? \"-100%\" : \"100%\", opacity: 0 }}\n                transition={{ duration: 0.42, ease: [0.22, 1, 0.36, 1], delay: place * 0.04 }}\n              >\n                {c}\n              </motion.span>\n            </AnimatePresence>\n          </span>\n        );\n      })}\n    </span>\n  );\n}\n\n/* ── the effects ───────────────────────────────────────────\n   Two ways for a like to land, one knob. Every one plays once\n   per press from a layer keyed by the press, and every number\n   in them is fixed rather than random: several copies share a\n   wall and a bench, and must all do the same thing. */\nexport const EFFECTS = [\"Bloom\", \"Firework\"] as const;\n\n/* a spread of fixed \"random\" numbers, one per particle */\nconst jit = (k: number, seed: number) => {\n  const x = Math.sin(k * 12.9898 + seed * 78.233) * 43758.5453;\n  return x - Math.floor(x);\n};\n\nfunction Burst({ fx, fly, ink }: { fx: string; fly: number; ink: boolean }) {\n  const c = (k: number) => (ink ? \"var(--lk-on)\" : CONFETTI[k % CONFETTI.length]);\n  const style = (o: Record<string, string | number>) => o as React.CSSProperties;\n\n  if (fx === \"Firework\") {\n    /* thrown up and out, then they fall: the x is steady, the y\n       is its own element on a rise-then-drop curve */\n    return (\n      <>\n        {Array.from({ length: 12 }, (_, k) => {\n          const a = -Math.PI / 2 + (k / 11 - 0.5) * Math.PI * 1.25;\n          const v = 22 + fly * 22 + jit(k, 7) * 10;\n          return (\n            <span key={k} className=\"lk-fw\" style={style({ \"--x\": `${Math.cos(a) * v}px`, \"--d\": `${jit(k, 8) * 60}ms` })}>\n              <i style={style({ \"--y\": `${Math.sin(a) * v}px`, background: c(k) })} />\n            </span>\n          );\n        })}\n      </>\n    );\n  }\n  /* Bloom: a disc that hollows into a ring, and pairs of confetti */\n  return (\n    <>\n      <span className=\"lk-bloom\" />\n      {Array.from({ length: 7 }, (_, k) => (\n        <span key={k} className=\"lk-spoke\" style={style({ \"--a\": `${k * (360 / 7) - 90}deg` })}>\n          <i style={style({ \"--c\": c(k) })} />\n          <i style={style({ \"--c\": c(k + 3) })} />\n        </span>\n      ))}\n    </>\n  );\n}\n\nexport function Like({\n  /* the count before you press */\n  start = 1300,\n  /* how the like lands */\n  effect = \"Bloom\",\n  /* how far the particles fly, 0..100 */\n  burst = 50,\n  color = \"Red\",\n  corner = H / 2,\n}: {\n  start?: number;\n  effect?: string;\n  burst?: number;\n  color?: string;\n  corner?: number;\n} = {}) {\n  const base = Math.max(0, Math.round(start));\n  const [liked, setLiked] = useState(false);\n  const [beat, setBeat] = useState(0);\n  const count = base + (liked ? 1 : 0);\n  const fly = clamp(burst, 0, 100) / 100;\n  const r = clamp(corner, 0, H / 2);\n  const ink = color === \"Ink\";\n  const fx = (EFFECTS as readonly string[]).includes(effect) ? effect : \"Bloom\";\n\n  const press = () => {\n    const next = !liked;\n    setLiked(next);\n    if (next) {\n      setBeat((b) => b + 1);\n    }\n  };\n\n  return (\n    <div className=\"lk-frame\">\n      <button\n        type=\"button\"\n        className=\"lk\"\n        data-liked={liked || undefined}\n        data-color={color}\n        data-fx={fx}\n        aria-pressed={liked}\n        aria-label={`Like. ${fmt(count)} likes`}\n        style={{ height: H, \"--r\": `${r}px`, \"--lk-on\": ink ? \"var(--bencho-fill-on, var(--bencho-ink))\" : RED } as React.CSSProperties}\n        onClick={press}\n      >\n        <span className=\"lk-heart\">\n          {/* keyed by the press, so every like plays once */}\n          <span key={liked ? `on${beat}` : \"off\"} className=\"lk-glyph\" data-on={liked || undefined}>\n            <Heart size={20} strokeWidth={2} fill={liked ? \"currentColor\" : \"none\"} />\n          </span>\n          {liked && fly > 0 && (\n            <span key={beat} className=\"lk-burst\" style={{ \"--fly\": fly } as React.CSSProperties} aria-hidden=\"true\">\n              <Burst fx={fx} fly={fly} ink={ink} />\n            </span>\n          )}\n        </span>\n        <Roll value={count} up={liked} />\n      </button>\n    </div>\n  );\n}\n"
    },
    {
      "path": "registry/bencho/like/Like.css",
      "type": "registry:file",
      "target": "@components/bencho/like/Like.css",
      "content": "/* ══ Like ═════════════════════════════════════════════════ */\n/* a fixed frame: the pill grows by a digit at 9,999 and the\n   block must not rescale on the wall when it does */\n.lk-frame {\n  width: 240px;\n  height: 130px;\n  display: grid;\n  place-items: center;}\n\n.lk {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  padding: 0 20px 0 16px;\n  border: 0;\n  border-radius: var(--r);\n  background: var(--bencho-fill-slab, var(--bencho-card));\n  color: var(--bencho-fill-on, var(--bencho-ink));\n  font: inherit;\n  font-family: var(--bencho-font-ui);\n  font-size: 16px;\n  font-weight: 500;\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  transition: scale 220ms cubic-bezier(0.22, 1, 0.36, 1);\n  letter-spacing: -0.01em;}\n\n[data-stroke=\"on\"] .lk { box-shadow: inset 0 0 0 1px var(--bencho-pane-edge); }\n\n.lk:active { scale: 0.96; }\n\n.lk:focus-visible {\n  outline: none;\n  box-shadow: 0 0 0 2px var(--bencho-fill-slab, #fff), 0 0 0 4px var(--bencho-signal, #2231dd);}\n\n.lk-heart {\n  position: relative;\n  display: grid;\n  place-items: center;\n  width: 20px;\n  height: 20px;}\n\n.lk-glyph { position: relative; z-index: 1; display: grid; }\n\n/* the heart is gone while the bloom happens, then springs in\n   from nothing, red, past its size and back */\n.lk-glyph[data-on] {\n  color: var(--lk-on);\n  /* the default landing: squeeze, swell past its size, settle */\n  animation: lk-pop 520ms cubic-bezier(0.3, 1.5, 0.4, 1) both;}\n\n.lk[data-fx=\"Bloom\"] .lk-glyph[data-on] {\n  animation: lk-heart 760ms cubic-bezier(0.3, 1.6, 0.4, 1) both;}\n\n.lk-burst {\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  pointer-events: none;}\n\n/* the bloom: a full disc that grows, then hollows out from the\n   middle into a ring and thins to nothing — a border as wide as\n   the radius is a disc, and a border going to 0 is the hole */\n.lk-bloom {\n  position: absolute;\n  left: -18px;\n  top: -18px;\n  width: 34px;\n  height: 34px;\n  box-sizing: border-box;\n  border-radius: 50%;\n  border: 17px solid #cc8ef5;\n  animation: lk-bloom 560ms cubic-bezier(0.25, 0.8, 0.35, 1) both;}\n\n.lk[data-color=\"Ink\"] .lk-bloom { border-color: var(--lk-on); animation-name: lk-bloom-ink; }\n\n/* seven spokes, each a pair of dots, thrown as the ring opens */\n.lk-spoke {\n  position: absolute;\n  left: 0;\n  top: 0;\n  rotate: var(--a);}\n\n.lk-spoke i {\n  position: absolute;\n  width: 5px;\n  height: 5px;\n  margin: -2.5px 0 0 -2.5px;\n  border-radius: 50%;\n  background: var(--c);\n  animation: lk-dot 620ms cubic-bezier(0.2, 0.8, 0.3, 1) 200ms both;}\n\n/* the pair sits either side of the spoke, one a little behind */\n.lk-spoke i:first-child { --side: -4px; --far: 0px; }\n\n.lk-spoke i:last-child { --side: 4px; --far: -5px; width: 4px; height: 4px; margin: -2px 0 0 -2px; }\n\n/* ── Firework: up and out, then they fall ────── */\n.lk-fw {\n  position: absolute;\n  left: 0;\n  top: 0;\n  animation: lk-fw-x 1000ms cubic-bezier(0.2, 0.7, 0.4, 1) var(--d) both;}\n\n.lk-fw i {\n  position: absolute;\n  left: -2px;\n  top: -2px;\n  width: 4px;\n  height: 4px;\n  border-radius: 50%;\n  animation: lk-fw-y 1000ms linear var(--d) both;}\n\n/* the count: one wheel per digit, each its own window */\n.lk-count {\n  display: flex;\n  font-variant-numeric: tabular-nums;\n  line-height: 1;}\n\n.lk-wheel {\n  position: relative;\n  display: inline-block;\n  height: 1.25em;\n  overflow: hidden;}\n\n.lk-digit {\n  display: block;\n  line-height: 1.25em;}\n\n.lk-comma { line-height: 1.25em; }\n\n@media (prefers-reduced-motion: reduce) {\n  .lk-glyph[data-on], .lk-bloom, .lk-spoke i, .lk-fw, .lk-fw i { animation: none; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .lk-burst { display: none; }\n}\n\n@keyframes lk-pop {\n  0% { scale: 0.6; }\n  45% { scale: 1.28; }\n  100% { scale: 1; }}\n\n@keyframes lk-heart {\n  0%, 28% { scale: 0; }\n  62% { scale: 1.25; }\n  100% { scale: 1; }}\n\n@keyframes lk-bloom {\n  0% { scale: 0.15; border-width: 17px; border-color: #e5484d; }\n  40% { scale: 1; border-width: 17px; border-color: #cc8ef5; }\n  75% { border-width: 2px; opacity: 1; }\n  100% { scale: 1.12; border-width: 0; opacity: 0; border-color: #cc8ef5; }}\n\n@keyframes lk-bloom-ink {\n  0% { scale: 0.15; border-width: 17px; }\n  40% { scale: 1; border-width: 17px; }\n  75% { border-width: 2px; opacity: 1; }\n  100% { scale: 1.12; border-width: 0; opacity: 0; }}\n\n@keyframes lk-dot {\n  0% { translate: 12px var(--side); scale: 1; opacity: 0; }\n  12% { opacity: 1; }\n  100% { translate: calc(18px + var(--fly) * 14px + var(--far)) calc(var(--side) * 1.6); scale: 0; opacity: 1; }}\n\n@keyframes lk-fw-x { from { translate: 0 0; } to { translate: var(--x) 0; } }\n\n@keyframes lk-fw-y {\n  0% { translate: 0 0; opacity: 1; animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1); }\n  45% { translate: 0 var(--y); opacity: 1; animation-timing-function: cubic-bezier(0.5, 0, 0.8, 0.5); }\n  100% { translate: 0 calc(var(--y) + 30px); opacity: 0; }}"
    }
  ],
  "categories": [
    "press"
  ],
  "docs": "Like from Bencho — try it live and tune it at https://bencho.dev/blocks/like\n\n```tsx\nimport { Like } from \"@/components/bencho/like/Like\";\n\n<Like />\n```\n\nEvery prop is optional and defaults to what the block ships with on bencho.dev:\n\n- `color` (Color)\n- `effect` (Effect): how the like lands\n- `burst` (Burst): how far the particles fly\n- `corner` (Corner)",
  "meta": {
    "live": "https://bencho.dev/blocks/like",
    "license": "MIT"
  }
}
