diff --git a/src/components/sections/hero/HeroSplitTestimonial.tsx b/src/components/sections/hero/HeroSplitTestimonial.tsx index 474bfeb..3277803 100644 --- a/src/components/sections/hero/HeroSplitTestimonial.tsx +++ b/src/components/sections/hero/HeroSplitTestimonial.tsx @@ -5,6 +5,7 @@ import { cls } from "@/lib/utils"; import Button from "@/components/ui/Button"; import TextAnimation from "@/components/ui/TextAnimation"; import ImageOrVideo from "@/components/ui/ImageOrVideo"; +import MagneticButton from "@/components/ui/MagneticButton"; type Testimonial = { name: string; @@ -69,7 +70,9 @@ const HeroSplitTestimonial = ({ />
-
@@ -123,4 +126,4 @@ const HeroSplitTestimonial = ({ ); }; -export default HeroSplitTestimonial; +export default HeroSplitTestimonial; \ No newline at end of file diff --git a/src/components/ui/MagneticButton.tsx b/src/components/ui/MagneticButton.tsx new file mode 100644 index 0000000..c7cae04 --- /dev/null +++ b/src/components/ui/MagneticButton.tsx @@ -0,0 +1,42 @@ +"use client"; + +import { useRef, useState, MouseEvent, ReactNode } from "react"; +import { motion } from "motion/react"; + +interface MagneticButtonProps { + children: ReactNode; + className?: string; +} + +export default function MagneticButton({ children, className = "" }: MagneticButtonProps) { + const ref = useRef(null); + const [position, setPosition] = useState({ x: 0, y: 0 }); + + const handleMouse = (e: MouseEvent) => { + if (!ref.current) return; + const { clientX, clientY } = e; + const { height, width, left, top } = ref.current.getBoundingClientRect(); + const middleX = clientX - (left + width / 2); + const middleY = clientY - (top + height / 2); + setPosition({ x: middleX * 0.3, y: middleY * 0.3 }); + }; + + const reset = () => { + setPosition({ x: 0, y: 0 }); + }; + + const { x, y } = position; + + return ( + + {children} + + ); +} \ No newline at end of file