Put more of color-handling into JS code

This commit is contained in:
Sage Vaillancourt 2020-12-28 16:54:23 -05:00
parent 96eec63757
commit 1a83641e22
2 changed files with 4 additions and 2 deletions

View File

@ -38,7 +38,6 @@ ol, ul {
}
.square:focus {
background: #8d98e6;
outline: none;
}

View File

@ -70,7 +70,7 @@ function Square(props) {
let bg = {
backgroundImage: `url(${Images[props.value]})`,
backgroundSize: `11vw`,
// backgroundColor: "lightblue",
backgroundColor: props.bg,
};
if (props.value != null) {
return (
@ -353,10 +353,13 @@ class Board extends React.Component {
}
renderSquare(i) {
let bgColor = this.heldPiece() === i ?
"#5D98E6" : "white";
return (
<Square
value={this.state.squares[i]}
onClick={() => this.handleClick(i)}
bg={bgColor}
/>
);
}