"use client"; import { CSSProperties, ReactElement, ReactNode, useEffect, useRef, useState, } from "react"; import { cn } from "@/lib/utils"; interface NeonColorsProps { firstColor: string; secondColor: string; } interface NeonGradientCardProps { /** * @default
* @type ReactElement * @description * The component to be rendered as the card * */ as?: ReactElement; /** * @default "" * @type string * @description * The className of the card */ className?: string; /** * @default "" * @type ReactNode * @description * The children of the card * */ children?: ReactNode; /** * @default 5 * @type number * @description * The size of the border in pixels * */ borderSize?: number; /** * @default 20 * @type number * @description * The size of the radius in pixels * */ borderRadius?: number; /** * @default "{ firstColor: '#ff00aa', secondColor: '#00FFF1' }" * @type string * @description * The colors of the neon gradient * */ neonColors?: NeonColorsProps; [key: string]: any; } export const NeonGradientCard: React.FC = ({ className, children, borderSize = 2, borderRadius = 20, neonColors = { firstColor: "#ff00aa", secondColor: "#00FFF1", }, ...props }) => { const containerRef = useRef(null); const [dimensions, setDimensions] = useState({ width: 0, height: 0 }); useEffect(() => { const updateDimensions = () => { if (containerRef.current) { const { offsetWidth, offsetHeight } = containerRef.current; setDimensions({ width: offsetWidth, height: offsetHeight }); } }; updateDimensions(); window.addEventListener("resize", updateDimensions); return () => { window.removeEventListener("resize", updateDimensions); }; }, []); useEffect(() => { if (containerRef.current) { const { offsetWidth, offsetHeight } = containerRef.current; setDimensions({ width: offsetWidth, height: offsetHeight }); } }, [children]); return (
{children}
); };