Skip to content

Commit

Permalink
Refactor layout components (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjolowicz authored Jul 19, 2019
2 parents 2d93af7 + a948a39 commit 3b43f49
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 69 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix invalid generated URLs in webpack output.

### Changed
- Refactor layout components ([#115](../../issues/115)):
- Move Paper from SignUp to SignUpLayout.
- Move Header out of main in SignUpLayout.
- Eliminate Header component in layouts.
- Refactor artist components ([#111](../../issues/111)):
- Incorporate FetchingArtistList in ArtistList.
- Move Artist button to separate component.
Expand Down
10 changes: 2 additions & 8 deletions src/components/layouts/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ type Props = {
children: React.Node
};

export const Header = () => (
<>
<AppBar />
<Navigation />
</>
);

const useStyles = makeStyles(theme => ({
main: {
padding: theme.spacing(3)
Expand All @@ -33,7 +26,8 @@ const Layout = ({ children }: Props) => {
const classes = useStyles();
return (
<>
<Header />
<AppBar />
<Navigation />
<main className={classes.main}>
<Paper className={classes.paper}>{children}</Paper>
</main>
Expand Down
33 changes: 30 additions & 3 deletions src/components/layouts/SignUpLayout.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
// @flow
import * as React from "react";
import Paper from "@material-ui/core/Paper";
import { makeStyles } from "@material-ui/styles";

import { Header } from "./Layout";
import AppBar from "./AppBar";
import Navigation from "./Navigation";
import Message from "./Message";

type Props = {
children: React.Node
};

const useStyles = makeStyles(theme => ({
main: {
width: "auto",
marginLeft: theme.spacing(3),
marginRight: theme.spacing(3),
[theme.breakpoints.up(400 + theme.spacing(3 * 2))]: {
width: 400,
marginLeft: "auto",
marginRight: "auto"
}
},
paper: {
marginTop: theme.spacing(8),
display: "flex",
flexDirection: "column",
alignItems: "center",
padding: theme.spacing(2, 3, 3)
}
}));

const SignUpLayout = ({ children }: Props) => {
const classes = useStyles();
return (
<>
<Header />
{children}
<AppBar />
<Navigation />
<main className={classes.main}>
<Paper className={classes.paper}>{children}</Paper>
</main>
<Message />
</>
);
Expand Down
96 changes: 38 additions & 58 deletions src/components/user/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Redirect } from "react-router-dom";
import Input from "@material-ui/core/Input";
import FormControl from "@material-ui/core/FormControl";
import Button from "@material-ui/core/Button";
import Paper from "@material-ui/core/Paper";
import Typography from "@material-ui/core/Typography";
import { makeStyles } from "@material-ui/styles";

Expand All @@ -24,23 +23,6 @@ type Props = {
type ButtonEvent = SyntheticInputEvent<HTMLButtonElement>;

const useStyles = makeStyles(theme => ({
main: {
width: "auto",
marginLeft: theme.spacing(3),
marginRight: theme.spacing(3),
[theme.breakpoints.up(400 + theme.spacing(3 * 2))]: {
width: 400,
marginLeft: "auto",
marginRight: "auto"
}
},
paper: {
marginTop: theme.spacing(8),
display: "flex",
flexDirection: "column",
alignItems: "center",
padding: theme.spacing(2, 3, 3)
},
form: {
marginTop: theme.spacing(1)
},
Expand All @@ -65,47 +47,45 @@ export const SignUp = ({ createUser, user }: Props) => {
}

return (
<main className={classes.main}>
<Paper className={classes.paper}>
<Typography component="h1" variant="h5">
Sign up for Muckr
</Typography>
<form className={classes.form} onSubmit={handleSubmit}>
<FormControl margin="normal" required fullWidth>
<Input
autoFocus
fullWidth
autoComplete="username"
name="username"
type="text"
value={username}
placeholder="Username"
onChange={handleUsernameChange}
/>
</FormControl>
<FormControl margin="normal" required fullWidth>
<Input
fullWidth
autoComplete="new-password"
name="password"
type="password"
value={password}
placeholder="Password"
onChange={handlePasswordChange}
/>
</FormControl>
<Button
className={classes.submit}
<>
<Typography component="h1" variant="h5">
Sign up for Muckr
</Typography>
<form className={classes.form} onSubmit={handleSubmit}>
<FormControl margin="normal" required fullWidth>
<Input
autoFocus
fullWidth
autoComplete="username"
name="username"
type="text"
value={username}
placeholder="Username"
onChange={handleUsernameChange}
/>
</FormControl>
<FormControl margin="normal" required fullWidth>
<Input
fullWidth
type="submit"
variant="contained"
color="primary"
>
Sign up
</Button>
</form>
</Paper>
</main>
autoComplete="new-password"
name="password"
type="password"
value={password}
placeholder="Password"
onChange={handlePasswordChange}
/>
</FormControl>
<Button
className={classes.submit}
fullWidth
type="submit"
variant="contained"
color="primary"
>
Sign up
</Button>
</form>
</>
);
};

Expand Down

0 comments on commit 3b43f49

Please sign in to comment.