'use client'; import { forwardRef, useEffect, useRef, HTMLAttributes } from 'react'; import styles from './radar-scan.module.css'; export interface RadarScanProps extends HTMLAttributes { /** Scan color */ color?: string; /** Scan line speed (rotation per second) */ speed?: number; /** Radar size in pixels */ size?: number; /** Number of rings */ rings?: number; /** Number of blips/targets to show */ blips?: Array<{ angle: number; distance: number }>; /** Enable pulse effect on blips */ pulseBlips?: boolean; /** Scan width */ scanWidth?: number; } export const RadarScan = forwardRef( ( { color = 'rgba(0, 255, 0, 0.8)', speed = 1, size = 300, rings = 4, blips = [], pulseBlips = true, scanWidth = 2, className, style, ...props }, ref ) => { const scanRef = useRef(null); useEffect(() => { const scan = scanRef.current; if (!scan) return; scan.style.animationDuration = `${1 / speed}s`; }, [speed]); return (
{/* Rings */}
{Array.from({ length: rings }).map((_, i) => (
))}
{/* Crosshairs */}
{/* Blips/Targets */}
{blips.map((blip, i) => (
))}
{/* Scan Line */}
{/* Glow effect */}
); } ); RadarScan.displayName = 'RadarScan'; export default RadarScan;