dao-game / react-multiplayer / files / src / react / Piece.tsx
Branch react-multiplayer · default branch · all branches
Piece.tsx
| 1 | import * as React from 'react'; |
| 2 | import './Piece.css'; |
| 3 | |
| 4 | export type Props = { |
| 5 | isPlayer1: boolean, |
| 6 | isCurrentPlayer: boolean, |
| 7 | isSelectedPiece: boolean, |
| 8 | clickCb: () => void |
| 9 | } |
| 10 | export const Piece = (props: Props): React.ReactElement => { |
| 11 | const { isPlayer1, isCurrentPlayer, isSelectedPiece } = props; |
| 12 | const classNames = [ |
| 13 | 'piece', |
| 14 | isPlayer1 ? 'p1-piece' : 'p2-piece', |
| 15 | isCurrentPlayer && 'active-player-piece', |
| 16 | isSelectedPiece && 'selected-piece' |
| 17 | ]; |
| 18 | |
| 19 | return ( |
| 20 | <div className={classNames.join(' ')} onClick={props.clickCb} /> |
| 21 | ) |
| 22 | }; |