Checker the board

This commit is contained in:
Sage Vaillancourt 2020-12-28 17:51:09 -05:00
parent 0cd2615959
commit 63dba59d25
2 changed files with 4 additions and 10 deletions

View File

@ -42,6 +42,7 @@ ol, ul {
margin-top: -1px; margin-top: -1px;
padding: 0; padding: 0;
text-align: center; text-align: center;
outline: none;
} }
.square:hover { .square:hover {

View File

@ -72,7 +72,6 @@ function Square(props) {
backgroundSize: `100%`, backgroundSize: `100%`,
backgroundColor: props.bg, backgroundColor: props.bg,
}; };
if (props.value != null) {
return ( return (
<button <button
className="square" className="square"
@ -81,14 +80,6 @@ function Square(props) {
> >
</button> </button>
); );
} else {
return (
<button
className="square"
onClick={props.onClick}
></button>
);
}
} }
class Board extends React.Component { class Board extends React.Component {
@ -353,8 +344,10 @@ class Board extends React.Component {
} }
renderSquare(i) { renderSquare(i) {
let plainBg = (i + (Math.floor(i / 8))) % 2 === 0 ?
"white" : "#666";
let bgColor = this.heldPiece() === i ? let bgColor = this.heldPiece() === i ?
"#5D98E6" : "white"; "#5D98E6" : plainBg;
return ( return (
<Square <Square
value={this.state.squares[i]} value={this.state.squares[i]}