|
@@ -1,11 +1,10 @@
|
|
|
import React from "react";
|
|
|
import styled from "styled-components";
|
|
|
-import ClickToCopy from "../../util/ClickToCopy";
|
|
|
import LobbyPlayerList from "./LobbyPlayerList";
|
|
|
-import DelayedButton from "../../util/DelayedButton";
|
|
|
import HeaderAndFooter from "../../util/HeaderAndFooter";
|
|
|
-import { dispatch, useGameId, usePlayerName, useGameJoined } from "../../../domain/gameStore";
|
|
|
+import { useGameJoined } from "../../../domain/gameStore";
|
|
|
import JoinForm from "./JoinForm";
|
|
|
+import LobbyInfo from "./LobbyInfo";
|
|
|
|
|
|
const InfoContainer = styled.div`
|
|
|
flex: 3;
|
|
@@ -17,16 +16,6 @@ const InfoContainer = styled.div`
|
|
|
align-items: center;
|
|
|
`
|
|
|
|
|
|
-const Label = styled.span`
|
|
|
- padding: 0.2em;
|
|
|
-`
|
|
|
-
|
|
|
-const StyledDelayButton = styled(DelayedButton)`
|
|
|
- padding: 1em;
|
|
|
- margin: 0.2em;
|
|
|
- margin-top: 0.3em;
|
|
|
-`
|
|
|
-
|
|
|
const PageContainer = styled.div`
|
|
|
flex: 1;
|
|
|
display: flex;
|
|
@@ -35,31 +24,6 @@ const PageContainer = styled.div`
|
|
|
align-items: flex-start;
|
|
|
`
|
|
|
|
|
|
-const getUrl = gameId => {
|
|
|
- const u = new URL(window.location.href);
|
|
|
- u.searchParams.append("join", gameId);
|
|
|
- return u.href;
|
|
|
-}
|
|
|
-
|
|
|
-const LobbyInfo = () => {
|
|
|
- const gameId = useGameId();
|
|
|
- const playerName = usePlayerName();
|
|
|
-
|
|
|
- return (
|
|
|
- <>
|
|
|
- <Label>Playing as {playerName}</Label>
|
|
|
- <Label>Use this link to invite other players:</Label>
|
|
|
- <Label><ClickToCopy text={getUrl(gameId)} /></Label>
|
|
|
- <StyledDelayButton
|
|
|
- onEnd={dispatch.startRound}
|
|
|
- countDownFormatter={rem => `Click to cancel, ${rem}s...`}
|
|
|
- >
|
|
|
- Start Game
|
|
|
- </StyledDelayButton>
|
|
|
- </>
|
|
|
- )
|
|
|
-};
|
|
|
-
|
|
|
const Lobby = ({ onStart }) => {
|
|
|
const joined = useGameJoined();
|
|
|
|