'use client'; import { useRef, ReactNode } from 'react'; interface SpotlightCardProps { children: ReactNode; className?: string; spotlightColor?: string; id?: string; style?: React.CSSProperties; } export default function SpotlightCard({ children, className = '', spotlightColor = 'amber', id, style }: SpotlightCardProps) { const cardRef = useRef(null); const handleMouseMove = (e: React.MouseEvent) => { if (!cardRef.current) return; const rect = cardRef.current.getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; cardRef.current.style.setProperty('--mouse-x', `${x}px`); cardRef.current.style.setProperty('--mouse-y', `${y}px`); const centerX = rect.width / 2; const centerY = rect.height / 2; const rotateX = ((y - centerY) / centerY) * -4; const rotateY = ((x - centerX) / centerX) * 4; cardRef.current.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(1.02)`; }; const handleMouseLeave = () => { if (!cardRef.current) return; cardRef.current.style.transform = 'perspective(1000px) rotateX(0deg) rotateY(0deg) scale(1)'; }; // Color mapping for spotlight const colorMap: Record = { amber: 'rgba(251, 191, 36, 0.08)', purple: 'rgba(168, 85, 247, 0.08)', emerald: 'rgba(52, 211, 153, 0.08)', }; const borderColorMap: Record = { amber: 'rgba(251, 191, 36, 0.5)', purple: 'rgba(168, 85, 247, 0.5)', emerald: 'rgba(52, 211, 153, 0.5)', }; const glowColor = colorMap[spotlightColor] || colorMap.amber; const borderColor = borderColorMap[spotlightColor] || borderColorMap.amber; return (
{/* Spotlight Background Glow */}
{/* Spotlight Border Effect */}
{/* Hover Top Gradient */}
{children}
); }