summaryrefslogtreecommitdiff
path: root/src/components/grid/GridComponent.tsx
blob: 75d65aab2533e773b9994dd51e63c2b39d5d7fd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React from 'react';

import type { Grid, GridCell } from '@/types/grid';
import { Cell } from '@/components/grid/Cell';

interface GridProps {
    grid: Grid;
    onCellInteract?: (cell: GridCell) => void;
}

export const GridComponent: React.FC<GridProps> = ({
    grid,
    onCellInteract,
}) => {
    return (
        <div className='grid'>
            {grid.map((row, i) => (
                <div className='grid-row' key={i}>
                    {row.map((cell, j) => (
                        <Cell
                            key={j}
                            cell={cell}
                            onClick={() => onCellInteract?.(cell)}
                        />
                    ))}
                </div>
            ))}
        </div>
    );
};