import c from "classnames"; import { useEffect, useRef } from "react"; export interface FlareProps { className?: string; backgroundClass: string; flareSize?: number; cssColorVar?: string; enabled?: boolean; } const SIZE_DEFAULT = 200; const CSS_VAR_DEFAULT = "--colors-global-accentA"; export function Flare(props: FlareProps) { const outerRef = useRef(null); const size = props.flareSize ?? SIZE_DEFAULT; const cssVar = props.cssColorVar ?? CSS_VAR_DEFAULT; useEffect(() => { function mouseMove(e: MouseEvent) { if (!outerRef.current) return; outerRef.current.style.setProperty( "--bg-x", `${(e.clientX - size / 2).toFixed(0)}px` ); outerRef.current.style.setProperty( "--bg-y", `${(e.clientY - size / 2).toFixed(0)}px` ); } document.addEventListener("mousemove", mouseMove); return () => document.removeEventListener("mousemove", mouseMove); }, [size]); return (
); }