diff --git a/packages/ui/src/card.tsx b/packages/ui/src/card.tsx index 2ab6157a0..d87d98b41 100644 --- a/packages/ui/src/card.tsx +++ b/packages/ui/src/card.tsx @@ -76,45 +76,53 @@ const CardFooter = React.forwardRef< )); CardFooter.displayName = "CardFooter"; -const CardBorderIlluminated = (({ className, children, ...props }: - React.HTMLAttributes) => { - const divRef = React.useRef(null); +const CardBorderIlluminated = ({ + className, + children, + ...props +}: React.HTMLAttributes) => { + const divRef = React.useRef(null); const spotlightRef = React.useRef(null); - - React.useEffect(() => { + + React.useEffect(() => { const spotlightEl = spotlightRef.current; const parentEl = divRef.current?.ownerDocument; const divEl = divRef.current; if (!spotlightEl || !parentEl || !divEl) return; - const onMouseMove = (event: MouseEvent) => { + const onMouseMove = (event: MouseEvent) => { const rects = divEl.getBoundingClientRect(); spotlightEl.style.left = `${event.clientX - rects.x}px`; spotlightEl.style.top = `${event.clientY - rects.y}px`; - } + }; + + parentEl.addEventListener("mousemove", onMouseMove); - parentEl.addEventListener('mousemove',onMouseMove); - - return () => { - parentEl.removeEventListener('mousemove',onMouseMove); - } + return () => { + parentEl.removeEventListener("mousemove", onMouseMove); + }; }, [spotlightRef, divRef]); return (
-
-
{children}
+ > +
+
+ {children} +
); -}); +}; Card.displayName = "CardBorderIlluminated"; export {