'use client'; import { useRef, useState, useCallback, type ReactNode } from 'react'; import { motion } from 'framer-motion'; interface InkGlowCardProps { children: ReactNode; index?: number; accentColorRgb?: string; glowStart?: string; glowEnd?: string; className?: string; href?: string; onClick?: () => void; } const DEFAULT_ACCENT = '196, 30, 58'; const DEFAULT_GLOW_START = '#C41E3A'; const DEFAULT_GLOW_END = '#D97706'; export function InkGlowCard({ children, index = 0, accentColorRgb = DEFAULT_ACCENT, glowStart = DEFAULT_GLOW_START, glowEnd = DEFAULT_GLOW_END, className = '', href, onClick, }: InkGlowCardProps) { const cardRef = useRef(null); const [mousePos, setMousePos] = useState({ x: 0, y: 0 }); const [isHovered, setIsHovered] = useState(false); const handleMouseMove = useCallback((e: React.MouseEvent) => { if (!cardRef.current) return; const rect = cardRef.current.getBoundingClientRect(); setMousePos({ x: e.clientX - rect.left, y: e.clientY - rect.top, }); }, []); const content = ( <>
{children}
); return ( {href ? ( setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} > {content} ) : (
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} onClick={onClick} role={onClick ? 'button' : undefined} tabIndex={onClick ? 0 : undefined} > {content}
)}
); }