-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrid.js
More file actions
34 lines (25 loc) · 1.04 KB
/
Grid.js
File metadata and controls
34 lines (25 loc) · 1.04 KB
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
31
32
33
34
import React from "react";
import Box from "../Box/Box";
import "./Grid.css";
const Grid = ({gridchange, blockifiedgrid, darkmodevalue, shiftfocus}) => {
// "boxes" variable stores all the box components.
const boxes = blockifiedgrid.map((block,index) => <Box
key = {`box${index}`}
boxchange = {(value,rowNo,colNo) => gridchange(value,rowNo,colNo)}
block = {block}
darkmodevalue = {darkmodevalue}
boxindex = {index}
shiftfocus = {(rowNo,colNo,event) => shiftfocus(rowNo,colNo,event)}
/>);
const [gridClassName,setGridClassName] = React.useState("");
React.useEffect(() => {
// State variable "gridClassName" is changed whenever "darkmodevalue" prop is changed and this component is re-rendered.
darkmodevalue ? setGridClassName("grid-border-dark") : setGridClassName("grid-border-light");
},[darkmodevalue]);
return (
<div className = {`grid ${gridClassName}`}>
{boxes}
</div>
);
}
export default Grid;