From d7551f562d6b316100ea0aee285624b531b5648f Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Sun, 10 Jun 2018 18:33:01 +0200 Subject: Improve lobby's style --- frontend/src/components/game-browser/GameList.jsx | 2 +- frontend/src/components/lobby/Lobby.jsx | 20 +++++------- frontend/src/components/lobby/PlayerList.jsx | 37 +++++++++++++++-------- frontend/src/models/games.js | 2 ++ 4 files changed, 36 insertions(+), 25 deletions(-) (limited to 'frontend/src') diff --git a/frontend/src/components/game-browser/GameList.jsx b/frontend/src/components/game-browser/GameList.jsx index 08ce92e9..6363cff2 100644 --- a/frontend/src/components/game-browser/GameList.jsx +++ b/frontend/src/components/game-browser/GameList.jsx @@ -15,7 +15,7 @@ type GameListProps = { }; const GameListPresenter = ({ games, joinGame }: GameListProps) => ( - +
diff --git a/frontend/src/components/lobby/Lobby.jsx b/frontend/src/components/lobby/Lobby.jsx index ea865025..b4e323a8 100644 --- a/frontend/src/components/lobby/Lobby.jsx +++ b/frontend/src/components/lobby/Lobby.jsx @@ -3,33 +3,28 @@ import { Button } from '@blueprintjs/core'; import { List } from 'immutable'; import React, { Component } from 'react'; import { connect } from 'react-redux'; -import { PlayerList } from '../../components/lobby/PlayerList'; import type { Game } from '../../models/games'; import type { Player } from '../../models/players'; import { actions, getCurrentGame } from '../../redux/games'; -import { getPlayers } from '../../redux/players'; +import { getCurrentPlayer, getPlayers } from '../../redux/players'; +import { PlayerList } from './PlayerList'; export type LobbyProps = { currentGame: Game, + currentPlayer: Player, players: List, startGame: () => void, } class LobbyPresenter extends Component { - getTitle() { - if (this.props.currentGame) { - return this.props.currentGame.name + ' — Lobby'; - } else { - return 'What are you doing here? You haven\'t joined a game yet!'; - } - } render() { + const {currentGame, currentPlayer, players, startGame} = this.props; return (
-

{this.getTitle()}

- - +

{currentGame.name + ' — Lobby'}

+ +
); } @@ -40,6 +35,7 @@ const mapStateToProps = state => { console.info(game); return { currentGame: game, + currentPlayer: getCurrentPlayer(state), players: game ? getPlayers(state.get('players'), game.players) : new List(), }; }; diff --git a/frontend/src/components/lobby/PlayerList.jsx b/frontend/src/components/lobby/PlayerList.jsx index db3d4418..e0528c97 100644 --- a/frontend/src/components/lobby/PlayerList.jsx +++ b/frontend/src/components/lobby/PlayerList.jsx @@ -1,23 +1,36 @@ //@flow -import { Text } from '@blueprintjs/core'; +import { Icon, Text } from '@blueprintjs/core' import { List } from 'immutable'; -import React from 'react'; +import * as React from 'react'; import { Flex } from 'reflexbox'; import { Player } from '../../models/players'; type PlayerListProps = { - players: List; + players: List, + owner: string, + currentPlayer: Player, }; -const PlayerItem = ({player}) => ( - - {player.displayName} - ({player.username}) - +const PlayerListItem = ({player, isOwner, isUser}) => ( +
+ + + + ); -export const PlayerList = ({players}: PlayerListProps) => ( -
- {players.map(player => )} -
+export const PlayerList = ({players, owner, currentPlayer}: PlayerListProps) => ( +
+ + {isOwner && } + {isUser && } + + {player.displayName}{player.username}
+ + {players.map(player => )} + +
); diff --git a/frontend/src/models/games.js b/frontend/src/models/games.js index dfa0591d..7a8dfbc7 100644 --- a/frontend/src/models/games.js +++ b/frontend/src/models/games.js @@ -38,6 +38,7 @@ export type GameState = 'LOBBY' | 'PLAYING'; export type GameShape = { id: number, name: string | void, + owner: string, players: List, settings: SettingsType, state: GameState, @@ -49,6 +50,7 @@ export type GameNormalMapType = { [string]: GameShape }; const GameRecord: GameType = Record({ id: -1, name: null, + owner: 'anonymous', players: new List(), settings: new Settings(), state: 'LOBBY', -- cgit