diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2018-06-09 16:23:49 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2018-06-09 17:22:40 +0200 |
commit | b064ffab80cfccd0cfaa326275a5a3194e112be6 (patch) | |
tree | e136aeab7da5f52acbf65e1b1f36e41c2b4ab7a0 /frontend/src/components/game-browser/GameList.jsx | |
parent | Refresh dependencies (diff) | |
download | seven-wonders-b064ffab80cfccd0cfaa326275a5a3194e112be6.tar.gz seven-wonders-b064ffab80cfccd0cfaa326275a5a3194e112be6.tar.bz2 seven-wonders-b064ffab80cfccd0cfaa326275a5a3194e112be6.zip |
Improve game list's style
Diffstat (limited to 'frontend/src/components/game-browser/GameList.jsx')
-rw-r--r-- | frontend/src/components/game-browser/GameList.jsx | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/frontend/src/components/game-browser/GameList.jsx b/frontend/src/components/game-browser/GameList.jsx index e3601d51..5ec2303b 100644 --- a/frontend/src/components/game-browser/GameList.jsx +++ b/frontend/src/components/game-browser/GameList.jsx @@ -1,11 +1,13 @@ // @flow -import { Button, Text } from '@blueprintjs/core'; +import { Button, Icon } from '@blueprintjs/core'; import type { List } from 'immutable'; import React from 'react'; import { connect } from 'react-redux'; -import { Flex } from 'reflexbox'; import type { Game } from '../../models/games'; import { actions, getAllGames } from '../../redux/games'; +import './GameList.css'; +import { GameStatus } from './GameStatus'; +import { PlayerCount } from './PlayerCount'; type GameListProps = { games: List<Game>, @@ -13,18 +15,46 @@ type GameListProps = { }; const GameListPresenter = ({ games, joinGame }: GameListProps) => ( - <div> - {games.map((game: Game, index: number) => { - return ( - <Flex key={game.get('displayName', index)}> - <Text>{game.name}</Text> - <Button onClick={() => joinGame(game.id)}>Join</Button> - </Flex> - ); - })} - </div> + <table className='pt-html-table pt-interactive'> + <thead> + <GameListHeaderRow /> + </thead> + <tbody> + {games.map((game: Game) => <GameListItemRow key={game.id} game={game} joinGame={joinGame}/>)} + </tbody> + </table> ); +const GameListHeaderRow = () => ( + <tr> + <th>Name</th> + <th>Status</th> + <th>Nb Players</th> + <th>Join</th> + </tr> +); + +const GameListItemRow = ({game, joinGame}) => ( + <tr> + <td>{game.name}</td> + <td> + <GameStatus state={game.state} /> + </td> + <td> + <PlayerCount nbPlayers={game.players.size} /> + </td> + <td> + <JoinButton game={game} joinGame={joinGame}/> + </td> + </tr> +); + +const JoinButton = ({game, joinGame}) => { + const disabled = game.state !== 'LOBBY'; + const icon = <Icon icon='arrow-right' title={false} />; + return <Button minimal disabled={disabled} icon={icon} title='Join Game' onClick={() => joinGame(game.id)}/>; +}; + const mapStateToProps = state => ({ games: getAllGames(state.get('games')), }); |