"use client"; import { useState, useRef, useEffect } 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 [rotateX, setRotateX] = useState(0); const [rotateY, setRotateY] = useState(0); 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], ["10deg", "-10deg"]); const rotateYOutput = useTransform(springX, [-0.5, 0.5], ["-10deg", "10deg"]); 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 handleMouseLeave = () => { // Reset to neutral position when mouse leaves x.set(0); y.set(0); }; return ( {/* Ambient light reflection */}

{title}

{value}

{/* Shiny edge */}
); }