/* BackgroundRippleEffect — ported from the provided shadcn snippet to plain CSS classes. */
const { useMemo, useRef, useState, useEffect } = React;
function BackgroundRippleEffect({ rows = 8, cols = 27, cellSize = 56 }) {
const [clickedCell, setClickedCell] = useState(null);
const [rippleKey, setRippleKey] = useState(0);
return (
{
setClickedCell({ row, col });
setRippleKey((k) => k + 1);
}}
/>
);
}
function DivGrid({ rows, cols, cellSize, clickedCell, onCellClick }) {
const cells = useMemo(
() => Array.from({ length: rows * cols }, (_, idx) => idx),
[rows, cols]
);
const gridStyle = {
display: "grid",
gridTemplateColumns: `repeat(${cols}, ${cellSize}px)`,
gridTemplateRows: `repeat(${rows}, ${cellSize}px)`,
width: cols * cellSize,
height: rows * cellSize,
};
return (
{cells.map((idx) => {
const rowIdx = Math.floor(idx / cols);
const colIdx = idx % cols;
const distance = clickedCell
? Math.hypot(clickedCell.row - rowIdx, clickedCell.col - colIdx)
: 0;
const delay = clickedCell ? Math.max(0, distance * 55) : 0;
const duration = 200 + distance * 80;
const style = clickedCell
? { "--delay": `${delay}ms`, "--duration": `${duration}ms` }
: {};
return (
onCellClick(rowIdx, colIdx)}
/>
);
})}
);
}
window.BackgroundRippleEffect = BackgroundRippleEffect;