'use client';
import { HTMLAttributes, useId } from 'react';
export interface LightBeamsProps extends HTMLAttributes {
/** Beam color */
color?: string;
/** Animation intensity */
intensity?: 'subtle' | 'moderate' | 'intense';
/** Blur amount */
blur?: 'sharp' | 'medium' | 'blurred';
/** Animation duration in seconds */
duration?: number;
/** Which beams to show */
position?: 'edges' | 'corners' | 'all';
}
export function LightBeams({
color = 'rgba(255, 255, 255, 0.8)',
intensity = 'moderate',
blur = 'medium',
duration = 4,
position = 'all',
className = '',
style,
children,
...props
}: LightBeamsProps) {
const id = useId();
const getOpacity = () => {
switch (intensity) {
case 'subtle': return 0.3;
case 'intense': return 0.9;
default: return 0.6;
}
};
const getWidth = () => {
switch (intensity) {
case 'subtle': return '50px';
case 'intense': return '150px';
default: return '100px';
}
};
const getBlur = () => {
switch (blur) {
case 'sharp': return '0px';
case 'blurred': return '20px';
default: return '10px';
}
};
const renderBeams = () => {
const beams = [];
const beamStyle = {
'--beam-color': color,
'--beam-opacity': getOpacity(),
'--beam-width': getWidth(),
'--beam-blur': getBlur(),
} as React.CSSProperties;
if (position === 'edges' || position === 'all') {
beams.push(
,
,
,
);
}
if (position === 'corners' || position === 'all') {
const baseDiagonalClass = "absolute opacity-0 pointer-events-none h-[var(--beam-width)] w-[200%]";
beams.push(
,
,
,
);
}
return beams;
};
return (
<>
{renderBeams()}
{children}
>
);
}
LightBeams.displayName = 'LightBeams';
export default LightBeams;