2023-04-16 02:36:27 +02:00
|
|
|
import React, {useState} from 'react';
|
2023-04-14 02:01:55 +02:00
|
|
|
|
2023-04-15 19:37:50 +02:00
|
|
|
export default function Cell({spec, rowIndex, cellIndex, showSolution}) {
|
2023-04-16 02:36:27 +02:00
|
|
|
const [mark, setMark] = useState(false);
|
2023-04-14 02:01:55 +02:00
|
|
|
let classes = "cell r" + rowIndex + " c" + cellIndex;
|
|
|
|
if (spec.top) classes += " top";
|
|
|
|
if (spec.right) classes += " right";
|
|
|
|
if (spec.bottom) classes += " bottom";
|
|
|
|
if (spec.left) classes += " left";
|
2023-04-15 19:37:50 +02:00
|
|
|
if (spec.solution && showSolution) classes += " solution";
|
2023-04-16 02:36:27 +02:00
|
|
|
if (mark) classes += " user";
|
2023-04-14 02:01:55 +02:00
|
|
|
return (
|
2023-04-16 02:36:27 +02:00
|
|
|
<div className={classes}
|
|
|
|
onMouseEnter={(e) => {
|
|
|
|
const leftPressed = e.buttons & 0x1;
|
|
|
|
if (leftPressed) {
|
|
|
|
setMark(!mark);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
onMouseLeave={(e) => {
|
|
|
|
const leftPressed = e.buttons & 0x1;
|
|
|
|
if (leftPressed) {
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
onClick={(e) => {
|
|
|
|
setMark(!mark);
|
|
|
|
}}/>
|
2023-04-14 02:01:55 +02:00
|
|
|
);
|
|
|
|
}
|