From 80399ac7b17c1b1f5b2bbfc8b39a886c42a9e7f2 Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Thu, 23 Apr 2020 08:13:15 -0700 Subject: [PATCH] Showing only first 5 games by default. --- src/components/join-game/JoinGame.jsx | 155 ++++++++++++++++---------- 1 file changed, 94 insertions(+), 61 deletions(-) diff --git a/src/components/join-game/JoinGame.jsx b/src/components/join-game/JoinGame.jsx index 91398ec..653247d 100644 --- a/src/components/join-game/JoinGame.jsx +++ b/src/components/join-game/JoinGame.jsx @@ -26,19 +26,23 @@ import { start } from '../app/actions.js' import LoginOrCreateAccount from '../login-or-create-account/LoginOrCreateAccount.jsx'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faArrowCircleLeft } from '@fortawesome/free-solid-svg-icons' +import { faArrowCircleLeft, faCaretDown } from '@fortawesome/free-solid-svg-icons' import NewGame from '../new-game/NewGame.jsx' const JoinGameScreens = { list: 'list', details: 'details' }; +const defaultMaxGames = 5; + class JoinGame extends React.Component { constructor(props) { super(props); this.state = { screen: JoinGameScreens.list, game: null, - showSignIn: false + showSignIn: false, + maxGames: defaultMaxGames, + maxOpenGames: defaultMaxGames }; } @@ -67,69 +71,98 @@ class JoinGame extends React.Component { this.setState(state => { return { showSignIn: !state.showSignIn }; }); } + showAllGames = (e) => { + e.preventDefault(); + this.setState({ maxGames: Number.MAX_SAFE_INTEGER }); + } + + showAllOpenGames = (e) => { + e.preventDefault(); + this.setState({ maxOpenGames: Number.MAX_SAFE_INTEGER }); + } + render() { + const { games, openGames } = this.props; return ( - - - - Join Game - + + + + + Join Game + )}> - - - {this.state.screen === JoinGameScreens.list ? - (<> -

My Games

- {(!this.props.user && !this.state.showSignIn) ? ( - Sign In to see your games - ) : (<>)} - {(!this.props.user && this.state.showSignIn) ? ( - <> -
- -
- - ) : (<>)} - -

Open Games

- - - ) - : ( - -

Game: {this.state.game.name}

- -
)} + + + {this.state.screen === JoinGameScreens.list ? + (<> +

My Games

+ {(!this.props.user && !this.state.showSignIn) ? ( + Sign In to see your games + ) : (<>)} + {(!this.props.user && this.state.showSignIn) ? ( + <> +
+ +
+ + ) : (<>)} + +

Open Games

+ + + ) + : ( + +

Game: {this.state.game.name}

+ +
)}