'use client';
import { forwardRef, HTMLAttributes } from 'react';
import styles from './glass-crack.module.css';
export interface GlassCrackProps extends HTMLAttributes {
/** Crack intensity */
intensity?: 'light' | 'medium' | 'heavy';
/** Crack pattern */
pattern?: 'spiderweb' | 'lightning' | 'shattered' | 'random';
/** Crack color */
color?: string;
/** Show glow effect */
glow?: boolean;
/** Number of crack lines */
crackCount?: number;
}
export const GlassCrack = forwardRef(
(
{
intensity = 'medium',
pattern = 'spiderweb',
color = 'rgba(255, 255, 255, 0.5)',
glow = false,
crackCount = 12,
className,
...props
},
ref
) => {
// Generate crack lines
const cracks = Array.from({ length: crackCount }, (_, i) => ({
id: i,
angle: (360 / crackCount) * i + Math.random() * 20 - 10,
length: 30 + Math.random() * 50,
curve: Math.random() * 20 - 10,
branches: Math.random() > 0.7 ? Math.floor(Math.random() * 3) + 1 : 0,
}));
return (
{cracks.map((crack) => (
))}
);
}
);
GlassCrack.displayName = 'GlassCrack';
export default GlassCrack;