|
@@ -6,7 +6,7 @@ import Loading from "../../util/Loading";
|
|
import PlayerNameInput from "../../util/PlayerNameInput";
|
|
import PlayerNameInput from "../../util/PlayerNameInput";
|
|
import LobbyPlayerList from "./LobbyPlayerList";
|
|
import LobbyPlayerList from "./LobbyPlayerList";
|
|
import { joinGame } from "../../../domain/GGSHService";
|
|
import { joinGame } from "../../../domain/GGSHService";
|
|
-import useCountdown from "../../util/Timer/useCountdown";
|
|
|
|
|
|
+import DelayedButton from "../../util/DelayedButton";
|
|
|
|
|
|
const InfoContainer = styled.div`
|
|
const InfoContainer = styled.div`
|
|
flex: 3;
|
|
flex: 3;
|
|
@@ -28,6 +28,12 @@ const FormButton = styled(Button)`
|
|
margin-top: 0.3em;
|
|
margin-top: 0.3em;
|
|
`
|
|
`
|
|
|
|
|
|
|
|
+const StyledDelayButton = styled(DelayedButton)`
|
|
|
|
+ padding: 1em;
|
|
|
|
+ margin: 0.2em;
|
|
|
|
+ margin-top: 0.3em;
|
|
|
|
+`
|
|
|
|
+
|
|
const PageContainer = styled.div`
|
|
const PageContainer = styled.div`
|
|
flex: 1;
|
|
flex: 1;
|
|
display: flex;
|
|
display: flex;
|
|
@@ -42,34 +48,19 @@ const getUrl = gameId => {
|
|
return u.href;
|
|
return u.href;
|
|
}
|
|
}
|
|
|
|
|
|
-const CountdownButton = ({ onCancelled, onEnd }) => {
|
|
|
|
- const [remaining, pause] = useCountdown(5, onEnd);
|
|
|
|
- return (
|
|
|
|
- <FormButton onClick={() => { pause(); onCancelled(); }}>
|
|
|
|
- {remaining !== 0 ? JSON.stringify(remaining) : "Starting!"}
|
|
|
|
- </FormButton>
|
|
|
|
- );
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const LobbyInfo = ({ gameId, playerName, onStart }) => {
|
|
|
|
- const [delayed, setDelayed] = useState(false);
|
|
|
|
-
|
|
|
|
- return (
|
|
|
|
- <InfoContainer>
|
|
|
|
- <Label>Playing as {playerName}</Label>
|
|
|
|
- <Label>Use this link to invite other players:</Label>
|
|
|
|
- <Label><ClickToCopy text={getUrl(gameId)} /></Label>
|
|
|
|
- {
|
|
|
|
- delayed
|
|
|
|
- ? <CountdownButton
|
|
|
|
- onCancelled={() => setDelayed(false)}
|
|
|
|
- onEnd={() => { setDelayed(false); onStart(); }}
|
|
|
|
- />
|
|
|
|
- : <FormButton onClick={() => setDelayed(true)}>Start Game</FormButton>
|
|
|
|
- }
|
|
|
|
- </InfoContainer>
|
|
|
|
- )
|
|
|
|
-};
|
|
|
|
|
|
+const LobbyInfo = ({ gameId, playerName, onStart }) => (
|
|
|
|
+ <InfoContainer>
|
|
|
|
+ <Label>Playing as {playerName}</Label>
|
|
|
|
+ <Label>Use this link to invite other players:</Label>
|
|
|
|
+ <Label><ClickToCopy text={getUrl(gameId)} /></Label>
|
|
|
|
+ <StyledDelayButton
|
|
|
|
+ onEnd={onStart}
|
|
|
|
+ countDownFormatter={rem => `Click to cancel, ${rem}s...`}
|
|
|
|
+ >
|
|
|
|
+ Start Game
|
|
|
|
+ </StyledDelayButton>
|
|
|
|
+ </InfoContainer>
|
|
|
|
+);
|
|
|
|
|
|
const JoinForm = ({ gameId, onGameJoined }) => {
|
|
const JoinForm = ({ gameId, onGameJoined }) => {
|
|
const [loading, setLoading] = useState(false);
|
|
const [loading, setLoading] = useState(false);
|