1import { cn } from '@/lib/utils';
2import React, { useEffect, useState } from 'react';
11 activeDivsClass?: string;
15 containerRef: React.RefObject<HTMLDivElement>;
17 const [blocks, setBlocks] = useState<JSX.Element[]>([]);
20 const updateBlocks = () => {
21 const container = containerRef.current;
23 const containerWidth = container.clientWidth;
24 const containerHeight = container.clientHeight;
25 const blockSize = containerWidth * 0.06; // Using 6% of section width for the block size
27 const columns = Math.floor(containerWidth / blockSize);
28 const rows = Math.floor(containerHeight / blockSize);
30 const newBlocks = Array.from({ length: columns }, (_, columnIndex) => (
31 <div key={columnIndex} className='w-[6vw] h-full'>
32 {Array.from({ length: rows }, (_, rowIndex) => (
36 `h-[6vh] w-full border-[1px] border-[#5dcece09] ${
38 activeDivs[columnIndex]?.has(rowIndex)
44 style={{ height: `${blockSize}px` }}
55 window.addEventListener('resize', updateBlocks);
57 return () => window.removeEventListener('resize', updateBlocks);
58 }, [activeDivs, activeDivsClass, divClass, containerRef]);
63 'flex h-full overflow-hidden top-0 -inset-0 left-0 absolute',