Skip to content

Commit

Permalink
added rudimentary lobby status indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerkrewson committed Sep 11, 2020
1 parent b8157db commit 06e2c16
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 48 deletions.
20 changes: 20 additions & 0 deletions components/molecules/LobbyStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Card } from "@zeit-ui/react";
import { JellyfishSpinner } from "react-spinners-kit";
import { ClientGame } from "../../types/types";

const LobbyStatus = ({ selectedGame }: LobbyStatusProps): JSX.Element => (
<Card>
<JellyfishSpinner />
<span>
{selectedGame
? selectedGame.name + " selected! Waiting for host to start..."
: "Waiting for host to select a game..."}
</span>
</Card>
);

type LobbyStatusProps = {
selectedGame: ClientGame;
};

export default LobbyStatus;
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import { Spacer } from "@zeit-ui/react";
import GameSelector from "./GameSelector";
import { Player, ClientGameLibrary } from "../../types/types";
import { useState } from "react";
import NameBox from "../atoms/NameBox";
import GameDetailBox from "../atoms/GameDetailBox";
import LobbyStatus from "../molecules/LobbyStatus";

const Lobby = ({
playerList,
gameLibrary,
onSelectGame,
selectedGame,
selectedGameId,
onStartGame,
resetName,
meId,
Expand All @@ -32,18 +31,11 @@ const Lobby = ({
) : (
<>
<Spacer y={1.25} />
{selectedGame ? (
<GameDetailBox
game={gameLibrary.gameList.find(
({ id }) => id === selectedGame
)}
allCategories={gameLibrary.categories}
readyToPlay={true}
showOnlyHostMessage={false}
/>
) : (
<NameBox name="No Game Selected" />
)}
<LobbyStatus
selectedGame={gameLibrary.gameList.find(
({ id }) => id === selectedGameId
)}
/>
<Spacer y={1} />
<ButtonGroup>
<PrimaryButton
Expand All @@ -53,7 +45,7 @@ const Lobby = ({
View games
</PrimaryButton>
<PrimaryButton
disabled={!selectedGame || !isHost}
disabled={!selectedGameId || !isHost}
onClick={onStartGame}
size="large"
type="error"
Expand Down Expand Up @@ -81,7 +73,7 @@ type LobbyProps = {
playerList: Array<Player>;
gameLibrary: ClientGameLibrary;
onSelectGame: (gameId: string) => void;
selectedGame: string;
selectedGameId: string;
onStartGame: () => void;
resetName: () => void;
meId: number;
Expand Down
6 changes: 3 additions & 3 deletions components/templates/GameLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import PlayerList from "../molecules/PlayerList";
const GameLayout = ({
gameState,
path,
selectedGame,
selectedGameId,
onExitGame,
onStartGame,
onHostGameLoaded,
Expand All @@ -24,7 +24,7 @@ const GameLayout = ({
} = gameState;

const { renameParams } = gameLibrary.gameList.find(
({ id }) => id == selectedGame
({ id }) => id == selectedGameId
);

const { name, isHost } = thisPlayer;
Expand Down Expand Up @@ -245,7 +245,7 @@ const GameLayout = ({

type GameLayoutProps = {
gameState: GameState;
selectedGame: string;
selectedGameId: string;
path: string;
onExitGame: () => void;
onStartGame: () => void;
Expand Down
121 changes: 121 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-ga": "^3.1.2",
"react-spinners-kit": "^1.9.1",
"socket.io": "^2.3.0",
"ws": "^7.3.1"
},
Expand Down
Loading

0 comments on commit 06e2c16

Please sign in to comment.