"use client"; import React, { useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { Check, Copy } from "lucide-react"; import { cn } from "../lib/utils"; interface AnimatedCopyButtonProps { /** The text that will be copied to the clipboard */ textToCopy: string; /** Optional classname for the button */ className?: string; /** Size of the button */ size?: "sm" | "md" | "lg"; /** Optional callback fired when copied */ onCopy?: () => void; } export function AnimatedCopyButton({ textToCopy, className, size = "md", onCopy, }: AnimatedCopyButtonProps) { const [isCopied, setIsCopied] = useState(false); const handleCopy = async () => { try { await navigator.clipboard.writeText(textToCopy); setIsCopied(true); if (onCopy) onCopy(); // Reset after 2 seconds setTimeout(() => { setIsCopied(false); }, 2000); } catch (err) { console.error("Failed to copy text: ", err); } }; const sizes = { sm: "h-8 w-8", md: "h-10 w-10", lg: "h-12 w-12", }; const iconSizes = { sm: "h-4 w-4", md: "h-5 w-5", lg: "h-6 w-6", }; return ( ); }