{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "heart-burst-button",
  "type": "registry:ui",
  "title": "Heart Burst Button",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Instagram and Twitter-style like button featuring an elastic scale-pop spring, expanding shockwave ring, radial multi-colored particle confetti sparks, and double-tap card preview.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/heart-burst-button.tsx",
      "content": "\"use client\";\n\nimport React, { useState } from \"react\";\nimport { motion, AnimatePresence } from \"framer-motion\";\nimport {\n  Heart,\n  Sparkles,\n  Share2,\n  MessageCircle,\n  Bookmark,\n  Volume2,\n  VolumeX,\n  RotateCcw,\n} from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface HeartBurstButtonProps {\n  /** Initial like state */\n  initialLiked?: boolean;\n  /** Initial like count */\n  initialCount?: number;\n  /** Size variant */\n  size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n  /** Color theme */\n  theme?: \"instagram\" | \"crimson\" | \"violet\" | \"gold\";\n  /** Callback when like state changes */\n  onToggle?: (liked: boolean, count: number) => void;\n  /** Extra container className */\n  className?: string;\n}\n\ninterface Particle {\n  id: number;\n  angle: number;\n  distance: number;\n  size: number;\n  color: string;\n}\n\nconst THEME_COLORS: Record<string, { primary: string; glow: string; particles: string[] }> = {\n  instagram: {\n    primary: \"text-rose-500 fill-rose-500\",\n    glow: \"shadow-rose-500/40\",\n    particles: [\"#FF385C\", \"#E0245E\", \"#FF5A5F\", \"#FA709A\", \"#FEE140\", \"#7928CA\"],\n  },\n  crimson: {\n    primary: \"text-red-600 fill-red-600\",\n    glow: \"shadow-red-600/40\",\n    particles: [\"#E50914\", \"#FF1E27\", \"#B81D24\", \"#FF6B6B\", \"#FFA07A\"],\n  },\n  violet: {\n    primary: \"text-fuchsia-500 fill-fuchsia-500\",\n    glow: \"shadow-fuchsia-500/40\",\n    particles: [\"#A855F7\", \"#D946EF\", \"#EC4899\", \"#8B5CF6\", \"#C084FC\"],\n  },\n  gold: {\n    primary: \"text-amber-500 fill-amber-500\",\n    glow: \"shadow-amber-500/40\",\n    particles: [\"#F59E0B\", \"#FBBF24\", \"#FCD34D\", \"#D97706\", \"#FEF08A\"],\n  },\n};\n\nconst SIZES = {\n  sm: { icon: \"h-4 w-4\", btn: \"h-8 px-2.5 text-xs gap-1.5\", ring: \"w-8 h-8\" },\n  md: { icon: \"h-5 w-5\", btn: \"h-10 px-3.5 text-sm gap-2\", ring: \"w-10 h-10\" },\n  lg: { icon: \"h-7 w-7\", btn: \"h-12 px-4.5 text-base gap-2.5\", ring: \"w-12 h-12\" },\n  xl: { icon: \"h-9 w-9\", btn: \"h-16 px-6 text-lg gap-3\", ring: \"w-16 h-16\" },\n};\n\nexport function HeartBurstButton({\n  initialLiked = false,\n  initialCount = 1420,\n  size = \"md\",\n  theme = \"instagram\",\n  onToggle,\n  className,\n}: HeartBurstButtonProps) {\n  const [isLiked, setIsLiked] = useState(initialLiked);\n  const [likeCount, setLikeCount] = useState(initialCount);\n  const [activeTheme, setActiveTheme] = useState<\"instagram\" | \"crimson\" | \"violet\" | \"gold\">(theme);\n  const [activeSize, setActiveSize] = useState<\"sm\" | \"md\" | \"lg\" | \"xl\">(size);\n  const [burstKey, setBurstKey] = useState(0);\n  const [cardDoubleTapBurst, setCardDoubleTapBurst] = useState<{ id: number; x: number; y: number } | null>(null);\n  const [soundEnabled, setSoundEnabled] = useState(false);\n\n  const colors = THEME_COLORS[activeTheme];\n  const sizeConfig = SIZES[activeSize];\n\n  // Generate 12 radial particles\n  const particles: Particle[] = Array.from({ length: 12 }).map((_, i) => {\n    const angle = (i * (360 / 12)) + (i % 2 === 0 ? 8 : -8);\n    const distance = 28 + (i % 3) * 10;\n    const pSize = 4 + (i % 3) * 2;\n    const color = colors.particles[i % colors.particles.length];\n    return { id: i, angle, distance, size: pSize, color };\n  });\n\n  const triggerLike = (forceState?: boolean) => {\n    const nextState = forceState !== undefined ? forceState : !isLiked;\n    setIsLiked(nextState);\n    const newCount = nextState ? likeCount + 1 : Math.max(0, likeCount - 1);\n    setLikeCount(newCount);\n    if (nextState) {\n      setBurstKey((prev) => prev + 1);\n    }\n    onToggle?.(nextState, newCount);\n  };\n\n  const handleCardDoubleClick = (e: React.MouseEvent<HTMLDivElement>) => {\n    const rect = e.currentTarget.getBoundingClientRect();\n    const x = e.clientX - rect.left;\n    const y = e.clientY - rect.top;\n\n    setCardDoubleTapBurst({ id: Date.now(), x, y });\n    if (!isLiked) {\n      triggerLike(true);\n    } else {\n      setBurstKey((prev) => prev + 1);\n    }\n  };\n\n  return (\n    <div\n      data-fullscreen-scroll\n      className={cn(\n        \"relative flex min-h-[520px] w-full flex-col justify-between overflow-hidden rounded-2xl border border-neutral-200 bg-neutral-50/70 p-4 sm:p-8 dark:border-neutral-800 dark:bg-neutral-950\",\n        className\n      )}\n    >\n      {/* Header bar */}\n      <div className=\"relative z-10 flex flex-wrap items-center justify-between gap-3 pb-3\">\n        <div className=\"flex items-center gap-3\">\n          <div className=\"flex h-9 w-9 items-center justify-center rounded-xl bg-rose-500/10 text-rose-600 dark:bg-rose-500/20 dark:text-rose-400\">\n            <Heart className=\"h-4 w-4 fill-rose-500\" />\n          </div>\n          <div>\n            <div className=\"flex items-center gap-2\">\n              <span className=\"text-sm font-semibold tracking-tight text-neutral-900 dark:text-neutral-100\">\n                Instagram Heart Burst Button\n              </span>\n              <span className=\"rounded-full bg-rose-500/10 px-2 py-0.5 text-[10px] font-semibold text-rose-600 dark:text-rose-400\">\n                Confetti &amp; Shockwave\n              </span>\n            </div>\n            <p className=\"text-xs text-neutral-500 dark:text-neutral-400\">\n              Elastic pop spring, expanding shockwave ring, radial particles, and photo double-tap\n            </p>\n          </div>\n        </div>\n\n        <div className=\"flex items-center gap-2\">\n          <button\n            type=\"button\"\n            onClick={() => setSoundEnabled(!soundEnabled)}\n            className=\"flex items-center gap-1.5 rounded-lg border border-neutral-200 bg-white px-2.5 py-1.5 text-xs font-medium text-neutral-700 shadow-xs transition hover:bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-800\"\n          >\n            {soundEnabled ? (\n              <>\n                <Volume2 className=\"h-3.5 w-3.5 text-rose-500\" />\n                <span>Haptic Audio On</span>\n              </>\n            ) : (\n              <>\n                <VolumeX className=\"h-3.5 w-3.5\" />\n                <span>Mute Audio</span>\n              </>\n            )}\n          </button>\n        </div>\n      </div>\n\n      {/* Main Showcase Stage */}\n      <div className=\"relative z-10 my-auto flex flex-col items-center justify-center py-6 sm:flex-row sm:gap-12\">\n        {/* Instagram Post Card with Double Tap Burst */}\n        <div className=\"relative w-full max-w-sm rounded-3xl border border-neutral-200/90 bg-white shadow-xl shadow-neutral-950/5 dark:border-neutral-800/90 dark:bg-neutral-900 dark:shadow-black/40\">\n          {/* Post Header */}\n          <div className=\"flex items-center justify-between border-b border-neutral-100 p-3.5 dark:border-neutral-800\">\n            <div className=\"flex items-center gap-2.5\">\n              <div className=\"h-8 w-8 rounded-full bg-gradient-to-tr from-amber-500 via-rose-500 to-purple-600 p-0.5\">\n                <div className=\"h-full w-full rounded-full bg-white dark:bg-neutral-900 flex items-center justify-center text-[11px] font-bold\">\n                  P\n                </div>\n              </div>\n              <div>\n                <div className=\"text-xs font-bold text-neutral-900 dark:text-white\">\n                  pulse.ui\n                </div>\n                <div className=\"text-[10px] text-neutral-400\">Kyoto, Japan</div>\n              </div>\n            </div>\n            <Sparkles className=\"h-4 w-4 text-neutral-400\" />\n          </div>\n\n          {/* Post Photo Canvas (Double Clickable) */}\n          <div\n            onDoubleClick={handleCardDoubleClick}\n            className=\"group relative h-64 w-full cursor-pointer select-none overflow-hidden bg-gradient-to-br from-indigo-900 via-slate-900 to-rose-950\"\n          >\n            {/* Visual backdrop details */}\n            <div className=\"absolute inset-0 flex flex-col items-center justify-center p-6 text-center text-white/90\">\n              <div className=\"mb-2 rounded-full border border-white/20 bg-white/10 px-3 py-1 text-[11px] font-medium backdrop-blur-md\">\n                Double tap anywhere to like\n              </div>\n              <p className=\"max-w-[200px] text-xs font-light text-white/70\">\n                Cherry blossoms blooming along the Philosopher&apos;s Path at dawn.\n              </p>\n            </div>\n\n            {/* Central Double Tap Big Heart Pop */}\n            <AnimatePresence>\n              {cardDoubleTapBurst && (\n                <motion.div\n                  key={cardDoubleTapBurst.id}\n                  initial={{ scale: 0, opacity: 0, rotate: -15 }}\n                  animate={{\n                    scale: [0, 1.4, 1.1, 1.2],\n                    opacity: [0, 1, 0.95, 0],\n                    rotate: [0, 10, -5, 0],\n                    y: [0, -20],\n                  }}\n                  transition={{ duration: 0.85, ease: [0.175, 0.885, 0.32, 1.275] }}\n                  style={{\n                    position: \"absolute\",\n                    left: cardDoubleTapBurst.x - 36,\n                    top: cardDoubleTapBurst.y - 36,\n                  }}\n                  className=\"pointer-events-none z-30\"\n                >\n                  <Heart className=\"h-20 w-20 fill-white text-white drop-shadow-2xl\" />\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </div>\n\n          {/* Post Action Bar */}\n          <div className=\"p-3.5\">\n            <div className=\"flex items-center justify-between\">\n              <div className=\"flex items-center gap-3\">\n                {/* Heart Burst Action */}\n                <div className=\"relative\">\n                  {/* Expanding Shockwave Ring */}\n                  <AnimatePresence>\n                    {isLiked && (\n                      <motion.div\n                        key={`ring-${burstKey}`}\n                        initial={{ scale: 0.2, opacity: 0.9 }}\n                        animate={{ scale: 2.4, opacity: 0 }}\n                        exit={{ opacity: 0 }}\n                        transition={{ duration: 0.5, ease: \"easeOut\" }}\n                        className={cn(\n                          \"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-rose-500\",\n                          sizeConfig.ring\n                        )}\n                      />\n                    )}\n                  </AnimatePresence>\n\n                  {/* Confetti Particles */}\n                  <AnimatePresence>\n                    {isLiked && (\n                      <div className=\"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2\">\n                        {particles.map((p) => {\n                          const rad = (p.angle * Math.PI) / 180;\n                          const targetX = Math.cos(rad) * p.distance;\n                          const targetY = Math.sin(rad) * p.distance;\n\n                          return (\n                            <motion.span\n                              key={`p-${burstKey}-${p.id}`}\n                              initial={{ scale: 0, x: 0, y: 0, opacity: 1 }}\n                              animate={{\n                                scale: [0, 1.3, 0],\n                                x: targetX,\n                                y: targetY,\n                                opacity: [1, 0.9, 0],\n                              }}\n                              transition={{\n                                duration: 0.55,\n                                ease: \"easeOut\",\n                                delay: (p.id % 4) * 0.02,\n                              }}\n                              style={{\n                                width: p.size,\n                                height: p.size,\n                                backgroundColor: p.color,\n                              }}\n                              className=\"absolute -translate-x-1/2 -translate-y-1/2 rounded-full shadow-xs\"\n                            />\n                          );\n                        })}\n                      </div>\n                    )}\n                  </AnimatePresence>\n\n                  {/* Elastic Heart Icon Button */}\n                  <motion.button\n                    type=\"button\"\n                    onClick={() => triggerLike()}\n                    whileTap={{ scale: 0.8 }}\n                    aria-label={isLiked ? \"Unlike post\" : \"Like post\"}\n                    className=\"relative z-10 flex items-center justify-center transition-colors focus-visible:outline-none\"\n                  >\n                    <motion.div\n                      key={`heart-${burstKey}`}\n                      animate={\n                        isLiked\n                          ? {\n                              scale: [1, 0.65, 1.45, 0.92, 1],\n                              rotate: [0, -12, 12, -4, 0],\n                            }\n                          : { scale: 1 }\n                      }\n                      transition={{ duration: 0.45, ease: \"easeInOut\" }}\n                    >\n                      <Heart\n                        className={cn(\n                          sizeConfig.icon,\n                          \"transition-colors duration-150\",\n                          isLiked\n                            ? colors.primary\n                            : \"text-neutral-700 hover:text-neutral-900 dark:text-neutral-300 dark:hover:text-white\"\n                        )}\n                      />\n                    </motion.div>\n                  </motion.button>\n                </div>\n\n                <MessageCircle className=\"h-5 w-5 text-neutral-700 hover:text-neutral-900 dark:text-neutral-300 dark:hover:text-white cursor-pointer\" />\n                <Share2 className=\"h-5 w-5 text-neutral-700 hover:text-neutral-900 dark:text-neutral-300 dark:hover:text-white cursor-pointer\" />\n              </div>\n\n              <Bookmark className=\"h-5 w-5 text-neutral-700 hover:text-neutral-900 dark:text-neutral-300 dark:hover:text-white cursor-pointer\" />\n            </div>\n\n            {/* Like Counter with Number Spring Animation */}\n            <div className=\"mt-2.5 flex items-center gap-1.5\">\n              <span className=\"text-xs font-bold text-neutral-900 dark:text-white\">\n                <AnimatePresence mode=\"popLayout\" initial={false}>\n                  <motion.span\n                    key={likeCount}\n                    initial={{ y: 8, opacity: 0 }}\n                    animate={{ y: 0, opacity: 1 }}\n                    exit={{ y: -8, opacity: 0 }}\n                    transition={{ duration: 0.2 }}\n                    className=\"inline-block font-mono\"\n                  >\n                    {likeCount.toLocaleString()}\n                  </motion.span>\n                </AnimatePresence>{\" \"}\n                likes\n              </span>\n            </div>\n\n            <p className=\"mt-1 text-xs text-neutral-700 dark:text-neutral-300\">\n              <span className=\"font-bold\">pulse.ui</span> Spring physics make tactile consumer interactions irresistible.\n            </p>\n          </div>\n        </div>\n\n        {/* Standalone Button Inspector & Variations */}\n        <div className=\"mt-6 flex flex-col items-center gap-5 sm:mt-0\">\n          <div className=\"text-center\">\n            <span className=\"text-[11px] font-semibold uppercase tracking-wider text-neutral-400\">\n              Standalone Interactive Button\n            </span>\n            <div className=\"mt-3 flex items-center justify-center\">\n              <button\n                type=\"button\"\n                onClick={() => triggerLike()}\n                className={cn(\n                  \"relative flex items-center rounded-full border border-neutral-200 bg-white shadow-md transition-all hover:shadow-lg dark:border-neutral-800 dark:bg-neutral-900\",\n                  sizeConfig.btn\n                )}\n              >\n                <motion.div\n                  key={`standalone-heart-${burstKey}`}\n                  animate={\n                    isLiked\n                      ? { scale: [1, 0.6, 1.45, 0.9, 1] }\n                      : { scale: 1 }\n                  }\n                  transition={{ duration: 0.4 }}\n                >\n                  <Heart\n                    className={cn(\n                      sizeConfig.icon,\n                      \"transition-colors\",\n                      isLiked ? colors.primary : \"text-neutral-400\"\n                    )}\n                  />\n                </motion.div>\n                <span className=\"font-mono font-semibold text-neutral-800 dark:text-neutral-200\">\n                  {likeCount.toLocaleString()}\n                </span>\n              </button>\n            </div>\n          </div>\n\n          {/* Theme Palette Chooser */}\n          <div className=\"rounded-2xl border border-neutral-200 bg-white p-3.5 shadow-xs dark:border-neutral-800 dark:bg-neutral-900\">\n            <div className=\"mb-2 text-[11px] font-medium text-neutral-500\">\n              Confetti Sparkle Theme:\n            </div>\n            <div className=\"flex items-center gap-2\">\n              {([\"instagram\", \"crimson\", \"violet\", \"gold\"] as const).map((t) => (\n                <button\n                  key={t}\n                  type=\"button\"\n                  onClick={() => setActiveTheme(t)}\n                  className={cn(\n                    \"capitalize rounded-lg px-2.5 py-1 text-xs font-semibold transition\",\n                    activeTheme === t\n                      ? \"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900\"\n                      : \"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700\"\n                  )}\n                >\n                  {t}\n                </button>\n              ))}\n            </div>\n\n            <div className=\"mt-3 border-t border-neutral-100 pt-3 dark:border-neutral-800\">\n              <div className=\"mb-2 text-[11px] font-medium text-neutral-500\">\n                Button Size:\n              </div>\n              <div className=\"flex items-center gap-1.5\">\n                {([\"sm\", \"md\", \"lg\", \"xl\"] as const).map((s) => (\n                  <button\n                    key={s}\n                    type=\"button\"\n                    onClick={() => setActiveSize(s)}\n                    className={cn(\n                      \"uppercase rounded-md px-2 py-0.5 text-[11px] font-mono font-medium transition\",\n                      activeSize === s\n                        ? \"bg-rose-500 text-white\"\n                        : \"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-300\"\n                    )}\n                  >\n                    {s}\n                  </button>\n                ))}\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n\n      {/* Footer reset bar */}\n      <div className=\"relative z-10 flex flex-wrap items-center justify-between gap-3 border-t border-neutral-200/80 pt-4 dark:border-neutral-800/80\">\n        <span className=\"text-xs text-neutral-500\">\n          State: <strong className=\"text-neutral-900 dark:text-white\">{isLiked ? \"Liked\" : \"Unliked\"}</strong> ({likeCount} total)\n        </span>\n        <button\n          type=\"button\"\n          onClick={() => {\n            setIsLiked(false);\n            setLikeCount(initialCount);\n          }}\n          className=\"flex items-center gap-1 text-xs text-neutral-500 underline transition hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white\"\n        >\n          <RotateCcw className=\"h-3 w-3\" />\n          <span>Reset Likes</span>\n        </button>\n      </div>\n    </div>\n  );\n}\n\nexport default HeartBurstButton;\n",
      "type": "registry:ui",
      "target": "components/ui/heart-burst-button.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
