X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=tictactoe%2Ftictactoe.jsx;h=d92b698fe57b913e8d8625643b18376bf0262947;hp=61a828eb751d6662e63681aa6e313cb6ed95dd20;hb=cd1247338dd987b8796ad5ca6d0f655ececa22ee;hpb=9c92603bbe96c1bb54db5247ba73e7ea447845c1 diff --git a/tictactoe/tictactoe.jsx b/tictactoe/tictactoe.jsx index 61a828e..d92b698 100644 --- a/tictactoe/tictactoe.jsx +++ b/tictactoe/tictactoe.jsx @@ -36,18 +36,31 @@ events.addEventListener("game-state", event => { }); function Square(props) { + let className = "square"; + + if (props.value) { + className += " occupied"; + } else if (props.active) { + className += " open"; + } + + const onClick = props.active ? props.onClick : null; + return ( - + ); } class Board extends React.Component { renderSquare(i) { + const value = this.props.squares[i]; return ( this.props.onClick(i)} /> ); @@ -173,6 +186,7 @@ class Game extends React.Component {
this.handleClick(i)} />