Commit 8157687b authored by 佚名's avatar 佚名 🎅🏼

feat: bg color

parent 2cd2423d
...@@ -5,6 +5,7 @@ import { Button } from './style'; ...@@ -5,6 +5,7 @@ import { Button } from './style';
const Square = (props) => { const Square = (props) => {
return ( return (
<Button <Button
className={props.value==='X' ? 'blue' : props.value==='O' ? 'red' : ''}
onClick={props.onClick} onClick={props.onClick}
> >
{props.value} {props.value}
......
...@@ -16,6 +16,12 @@ export const Button = styled.button` ...@@ -16,6 +16,12 @@ export const Button = styled.button`
&:focus { &:focus {
outline: none outline: none
} }
&.blue {
background: blue;
}
&.red {
background: red;
}
` `
export const BoardRow = styled.div` export const BoardRow = styled.div`
......
...@@ -38,7 +38,6 @@ export default { ...@@ -38,7 +38,6 @@ export default {
const history = state.history.slice(0, state.stepNumber + 1); const history = state.history.slice(0, state.stepNumber + 1);
const current = history[history.length - 1]; const current = history[history.length - 1];
const squares = current.squares.slice(); const squares = current.squares.slice();
console.log(action.payload)
if (calculateWinner(squares) || squares[action.payload]) { if (calculateWinner(squares) || squares[action.payload]) {
return {...state}; return {...state};
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment