"use client";
import { motion, useSpring, useTransform } from "motion/react";
import { useButtonClick } from "@/hooks/useButtonClick";
import { cls } from "@/lib/utils";
interface ButtonElasticProps {
text: string;
variant?: "primary" | "secondary";
href?: string;
onClick?: () => void;
animate?: boolean;
animationDelay?: number;
className?: string;
}
const ButtonElastic = ({ text, variant = "primary", href = "#", onClick, animate = true, animationDelay = 0, className = "" }: ButtonElasticProps) => {
const handleClick = useButtonClick(href, onClick);
const scale = useSpring(1, { stiffness: 300, damping: 10 });
const scaleX = useTransform(scale, [1, 1.08], [1, 1.08]);
const scaleY = useTransform(scale, [1, 1.08], [1, 0.95]);
const handleMouseEnter = () => {
if (window.innerWidth < 768) return;
scale.set(1.08);
setTimeout(() => scale.set(1), 100);
};
const button = (
{text}
);
if (!animate) return button;
return (
{button}
);
};
export default ButtonElastic;