"use client"; import React, { useRef, useState } from "react"; import { motion } from "framer-motion"; import { cn } from "@/lib/utils"; interface MagneticButtonProps { children: React.ReactNode; className?: string; strength?: number; } export function MagneticButton({ children, className, strength = 0.3, }: MagneticButtonProps) { const ref = useRef(null); const [position, setPosition] = useState({ x: 0, y: 0 }); const handleMouseMove = (e: React.MouseEvent) => { if (!ref.current) return; const rect = ref.current.getBoundingClientRect(); const x = e.clientX - rect.left - rect.width / 2; const y = e.clientY - rect.top - rect.height / 2; setPosition({ x: x * strength, y: y * strength }); }; const handleMouseLeave = () => { setPosition({ x: 0, y: 0 }); }; return ( {children} ); }