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 { .square:focus {
background: #8d98e6;
outline: none; outline: none;
} }

View File

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