summaryrefslogtreecommitdiff
path: root/frontend/src/components/game-browser/GameBrowser.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components/game-browser/GameBrowser.jsx')
-rw-r--r--frontend/src/components/game-browser/GameBrowser.jsx54
1 files changed, 54 insertions, 0 deletions
diff --git a/frontend/src/components/game-browser/GameBrowser.jsx b/frontend/src/components/game-browser/GameBrowser.jsx
new file mode 100644
index 00000000..db0bbb9a
--- /dev/null
+++ b/frontend/src/components/game-browser/GameBrowser.jsx
@@ -0,0 +1,54 @@
+// @flow
+import { Button, Classes, InputGroup, Intent } from '@blueprintjs/core';
+import React, { Component } from 'react';
+import { connect } from 'react-redux';
+import { Flex } from 'reflexbox';
+import { GameList } from './GameList';
+import { PlayerInfo } from '../PlayerInfo';
+import { actions } from '../../redux/games';
+
+export type GameBrowserProps = {
+ createGame: (gameName: string) => void,
+}
+
+class GameBrowserPresenter extends Component<GameBrowserProps> {
+
+ _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" justify='space-between' p={1}>
+ <InputGroup
+ placeholder="Game name"
+ name="game_name"
+ onChange={(e: SyntheticInputEvent<*>) => (this._gameName = e.target.value)}
+ rightElement={<CreateGameButton onClick={this.createGame}/>}
+ />
+ <PlayerInfo />
+ </Flex>
+ <GameList />
+ </div>
+ );
+ }
+}
+
+const CreateGameButton = ({onClick}) => (
+ <Button className={Classes.MINIMAL} onClick={onClick} intent={Intent.PRIMARY}>Create Game</Button>
+);
+
+const mapStateToProps = () => ({
+});
+
+const mapDispatchToProps = {
+ createGame: actions.requestCreateGame,
+};
+
+export const GameBrowser = connect(mapStateToProps, mapDispatchToProps)(GameBrowserPresenter);
bgstack15