fuzzyworld

dao-game / react-multiplayer / files / src / react / Piece.tsx

Branch react-multiplayer · default branch · all branches

Piece.tsx

Blame: the commit that last changed each line · file · history

417dc266 2022-03-23 Pavel Safronov1import * as React from 'react';
2import './Piece.css';
3
4export type Props = {
5 isPlayer1: boolean,
6 isCurrentPlayer: boolean,
7 isSelectedPiece: boolean,
8 clickCb: () => void
9}
10export 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};