summaryrefslogtreecommitdiff
path: root/frontend/src/scenes
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2018-06-09 13:36:45 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2018-06-09 13:36:45 +0200
commit73389ad516af4cb49873cc19c2dc65efc77d6eb8 (patch)
tree85ecfb9b15c1db0b01300e7b18b0d7ad2d1a2d76 /frontend/src/scenes
parentFix frontend gitignore (diff)
downloadseven-wonders-73389ad516af4cb49873cc19c2dc65efc77d6eb8.tar.gz
seven-wonders-73389ad516af4cb49873cc19c2dc65efc77d6eb8.tar.bz2
seven-wonders-73389ad516af4cb49873cc19c2dc65efc77d6eb8.zip
Split GameBrowser into multiple connected components
Diffstat (limited to 'frontend/src/scenes')
-rw-r--r--frontend/src/scenes/GameBrowser/index.js73
-rw-r--r--frontend/src/scenes/index.js2
2 files changed, 1 insertions, 74 deletions
diff --git a/frontend/src/scenes/GameBrowser/index.js b/frontend/src/scenes/GameBrowser/index.js
deleted file mode 100644
index 5a94e290..00000000
--- a/frontend/src/scenes/GameBrowser/index.js
+++ /dev/null
@@ -1,73 +0,0 @@
-// @flow
-import { Button, Classes, InputGroup, Intent, Text } from '@blueprintjs/core';
-import type { List } from 'immutable';
-import React, { Component } from 'react';
-import { connect } from 'react-redux';
-import { Flex } from 'reflexbox';
-import { GameList } from '../../components/gameList';
-import type { Game } from '../../models/games';
-import type { Player } from '../../models/players';
-import { actions, getAllGames } from '../../redux/games';
-import { getCurrentPlayer } from '../../redux/players';
-
-export type GameBrowserProps = {
- currentPlayer: Player,
- games: List<Game>,
- createGame: (gameName: string) => void,
- joinGame: (gameId: string) => void
-}
-
-class GameBrowserPresenter extends Component<GameBrowserProps> {
- props: {
- currentPlayer: Player,
- games: List<Game>,
- createGame: (gameName: string) => void,
- joinGame: (gameId: string) => void
- };
-
- _gameName: string | void = undefined;
-
- createGame = (e: SyntheticEvent<*>): void => {
- e.preventDefault();
- if (this._gameName !== undefined) {
- this.props.createGame(this._gameName);
- }
- };
-
- render() {
- return (
- <div>
- <Flex align="center" p={1}>
- <InputGroup
- placeholder="Game name"
- name="game_name"
- onChange={(e: SyntheticInputEvent<*>) => (this._gameName = e.target.value)}
- rightElement={<CreateGameButton onClick={this.createGame}/>}
- />
- <Text>
- <b>Username:</b>
- {' '}
- {this.props.currentPlayer && this.props.currentPlayer.displayName}
- </Text>
- </Flex>
- <GameList games={this.props.games} joinGame={this.props.joinGame} />
- </div>
- );
- }
-}
-
-const CreateGameButton = ({onClick}) => (
- <Button className={Classes.MINIMAL} onClick={onClick} intent={Intent.PRIMARY}>Create Game</Button>
-);
-
-const mapStateToProps = state => ({
- currentPlayer: getCurrentPlayer(state.get('players')),
- games: getAllGames(state.get('games')),
-});
-
-const mapDispatchToProps = {
- createGame: actions.requestCreateGame,
- joinGame: actions.requestJoinGame,
-};
-
-export const GameBrowser = connect(mapStateToProps, mapDispatchToProps)(GameBrowserPresenter);
diff --git a/frontend/src/scenes/index.js b/frontend/src/scenes/index.js
index 5d75f275..eb15e626 100644
--- a/frontend/src/scenes/index.js
+++ b/frontend/src/scenes/index.js
@@ -1,6 +1,6 @@
import React from 'react';
import { Redirect, Route, Switch } from 'react-router-dom';
-import { GameBrowser } from './GameBrowser';
+import { GameBrowser } from '../components/game-browser/GameBrowser';
import { Lobby } from './Lobby';
import { SplashScreen } from './SplashScreen';
bgstack15