"use client"; import { HeartIcon } from "lucide-react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { type ComponentProps, useEffect, useState } from "react"; import { cn } from "@/lib/utils"; function useReduce() { const reduce = useReducedMotion(); const [mounted, setMounted] = useState(false); useEffect(() => setMounted(true), []); return mounted && !!reduce; } const SPARKS = Array.from({ length: 8 }, (_, i) => i * 45); const out = [0.22, 1, 0.36, 1] as const; function Burst() { return ( {SPARKS.map((angle, i) => ( ))} ); } function Digit({ char, up, place, reduce }: { char: string; up: boolean; place: number; reduce: boolean }) { return ( (reduce ? { opacity: 0 } : { y: rising ? "-100%" : "100%", opacity: 0 }) }} > {char} ); } function RollingCount({ value, up, reduce }: { value: number; up: boolean; reduce: boolean }) { const chars = [...value.toLocaleString("en-US")]; return ( {chars.map((char, i) => { const place = chars.length - 1 - i; return ; })} ); } export interface LikeButtonProps extends Omit, "onChange"> { liked?: boolean; defaultLiked?: boolean; onLikedChange?: (liked: boolean) => void; count?: number; } export function LikeButton({ liked: likedProp, defaultLiked = false, onLikedChange, count, className, onClick, ...props }: LikeButtonProps) { const reduce = useReduce(); const [internal, setInternal] = useState(defaultLiked); const liked = likedProp ?? internal; const [bursts, setBursts] = useState(0); const total = count === undefined ? undefined : count + (liked ? 1 : 0); return ( ); }