"use client"; import { useState, useRef } from 'react'; import { motion, useMotionValue, useSpring, useTransform } from 'framer-motion'; interface StatCardProps { title: string; value: string; className?: string; } export default function StatCard({ title, value, className = "" }: StatCardProps) { const cardRef = useRef(null); const [isHovered, setIsHovered] = useState(false); const x = useMotionValue(0); const y = useMotionValue(0); // Spring animations for smoother movement const springX = useSpring(x, { stiffness: 150, damping: 20 }); const springY = useSpring(y, { stiffness: 150, damping: 20 }); // Transform mouse movement to rotation values const rotateXOutput = useTransform(springY, [-0.5, 0.5], ["7deg", "-7deg"]); const rotateYOutput = useTransform(springX, [-0.5, 0.5], ["-7deg", "7deg"]); const handleMouseMove = (e: React.MouseEvent) => { if (!cardRef.current) return; const rect = cardRef.current.getBoundingClientRect(); // Calculate mouse position relative to card (0-1) const mouseX = (e.clientX - rect.left) / rect.width; const mouseY = (e.clientY - rect.top) / rect.height; // Convert to -0.5 to 0.5 range x.set(mouseX - 0.5); y.set(mouseY - 0.5); }; const handleMouseEnter = () => { setIsHovered(true); }; const handleMouseLeave = () => { // Reset to neutral position when mouse leaves x.set(0); y.set(0); setIsHovered(false); }; return ( {/* Ambient light reflection */}
{/* Main content with 3D effect */}

{title}

{value}

{/* Shiny shimmer effect */}
); }