Files
grungnet/src/routes/Join.js
Mitchell McCaffrey 05cf20fe8b Added styling
co-authored-by: nthouliss <nthouliss@gmail.com>
2020-03-19 17:33:57 +11:00

45 lines
1023 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React, { useContext } from "react";
import { navigate } from "hookrouter";
import { Container, Box, Label, Input, Button, Flex } from "theme-ui";
import GameContext from "../contexts/GameContext";
function Join() {
const { gameId, setGameId } = useContext(GameContext);
function handleChange(event) {
setGameId(event.target.value);
}
function handleSubmit(event) {
event.preventDefault();
navigate("/game");
}
return (
<Container sx={{ maxWidth: "300px" }}>
<Flex
sx={{
flexDirection: "column",
height: "100vh",
justifyContent: "center"
}}
>
<Box as="form" onSubmit={handleSubmit}>
<Label htmlFor="id">Shove an ID in me</Label>
<Input
my={4}
id="id"
name="id"
value={gameId || ""}
onChange={handleChange}
/>
<Button>Go ʕʔ</Button>
</Box>
</Flex>
</Container>
);
}
export default Join;