Skip to content

Commit

Permalink
Separate styles from auth components (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
amalv committed Feb 11, 2019
1 parent d3a82f8 commit 73b1943
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 81 deletions.
48 changes: 7 additions & 41 deletions src/components/SignIn.js → src/components/SignIn/SignIn.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,24 @@
// @flow
import React from "react";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import CssBaseline from "@material-ui/core/CssBaseline";
import FormControl from "@material-ui/core/FormControl";
import Input from "@material-ui/core/Input";
import InputLabel from "@material-ui/core/InputLabel";
import LockOutlinedIcon from "@material-ui/icons/LockOutlined";
import Paper from "@material-ui/core/Paper";
import Typography from "@material-ui/core/Typography";
import { withTheme } from "@material-ui/core/styles";
import styled from "styled-components";
import type { Theme } from "@material-ui/core/styles/createMuiTheme";
import {
Base,
PaperStyled,
AvatarStyled,
Form,
SubmitButtonStyled,
} from "./SignIn.styles";

type Props = { theme: Theme };

const Base = styled.main`
width: auto;
display: block;
margin-left: ${theme => theme.spacing.unit * 3}px;
margin-right: ${theme => theme.spacing.unit * 3}px;
${theme => theme.breakpoints.up("md")} {
width: 400px;
margin-left: auto;
margin-right: auto;
}
`;

const PaperStyled = styled(Paper)`
margin-top: ${theme => theme.spacing.unit * 8}px;
display: flex;
flex-direction: column;
align-items: center;
padding: ${theme => theme.spacing.unit * 2}px ${theme =>
theme.spacing.unit * 3}px ${theme => theme.spacing.unit * 3}px;
}}
`;

const AvatarStyled = styled(Avatar)`
margin: ${theme => theme.spacing.unit}px;
background-color: ${theme => theme.palette.secondary.main};
`;

const Form = styled.form`
width: 100%;
margin-top: ${theme => theme.spacing.unit}px;
`;

const SubmitButtonStyled = styled(Button)`
margin-top: ${theme => theme.spacing.unit * 3}px;
`;

const SignIn = (props: Props) => {
// eslint-disable-next-line react/prop-types
const { theme } = props;
const { zIndex, ...rest } = theme;
return (
Expand Down
42 changes: 42 additions & 0 deletions src/components/SignIn/SignIn.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import styled from "styled-components";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import Paper from "@material-ui/core/Paper";

const Base = styled.main`
width: auto;
display: block;
margin-left: ${theme => theme.spacing.unit * 3}px;
margin-right: ${theme => theme.spacing.unit * 3}px;
${theme => theme.breakpoints.up("md")} {
width: 400px;
margin-left: auto;
margin-right: auto;
}
`;

const PaperStyled = styled(Paper)`
margin-top: ${theme => theme.spacing.unit * 8}px;
display: flex;
flex-direction: column;
align-items: center;
padding: ${theme => theme.spacing.unit * 2}px ${theme =>
theme.spacing.unit * 3}px ${theme => theme.spacing.unit * 3}px;
}}
`;

const AvatarStyled = styled(Avatar)`
margin: ${theme => theme.spacing.unit}px;
background-color: ${theme => theme.palette.secondary.main};
`;

const Form = styled.form`
width: 100%;
margin-top: ${theme => theme.spacing.unit}px;
`;

const SubmitButtonStyled = styled(Button)`
margin-top: ${theme => theme.spacing.unit * 3}px;
`;

export { Base, PaperStyled, AvatarStyled, Form, SubmitButtonStyled };
3 changes: 3 additions & 0 deletions src/components/SignIn/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import SignIn from "./SignIn";

export default SignIn;
47 changes: 7 additions & 40 deletions src/components/SignUp.js → src/components/SignUp/SignUp.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,23 @@
// @flow
import React from "react";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import CssBaseline from "@material-ui/core/CssBaseline";
import FormControl from "@material-ui/core/FormControl";
import Input from "@material-ui/core/Input";
import InputLabel from "@material-ui/core/InputLabel";
import LockOutlinedIcon from "@material-ui/icons/LockOutlined";
import Paper from "@material-ui/core/Paper";
import Typography from "@material-ui/core/Typography";
import { withTheme } from "@material-ui/core/styles";
import styled from "styled-components";
import type { Theme } from "@material-ui/core/styles/createMuiTheme";
import {
Base,
PaperStyled,
AvatarStyled,
Form,
SubmitButtonStyled,
} from "./SignUp.styles";

type Props = { theme: Theme };

const Base = styled.main`
width: auto;
display: block;
margin-left: ${theme => theme.spacing.unit * 3}px;
margin-right: ${theme => theme.spacing.unit * 3}px;
${theme => theme.breakpoints.up("md")} {
width: 400px;
margin-left: auto;
margin-right: auto;
}
`;

const PaperStyled = styled(Paper)`
margin-top: ${theme => theme.spacing.unit * 8}px;
display: flex;
flex-direction: column;
align-items: center;
padding: ${theme => theme.spacing.unit * 2}px ${theme =>
theme.spacing.unit * 3}px ${theme => theme.spacing.unit * 3}px;
}}
`;

const AvatarStyled = styled(Avatar)`
margin: ${theme => theme.spacing.unit}px;
background-color: ${theme => theme.palette.secondary.main};
`;

const Form = styled.form`
width: 100%;
margin-top: ${theme => theme.spacing.unit}px;
`;

const SubmitButtonStyled = styled(Button)`
margin-top: ${theme => theme.spacing.unit * 3}px;
`;

const SignUp = (props: Props) => {
const { theme } = props;
const { zIndex, ...rest } = theme;
Expand Down
42 changes: 42 additions & 0 deletions src/components/SignUp/SignUp.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import styled from "styled-components";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import Paper from "@material-ui/core/Paper";

const Base = styled.main`
width: auto;
display: block;
margin-left: ${theme => theme.spacing.unit * 3}px;
margin-right: ${theme => theme.spacing.unit * 3}px;
${theme => theme.breakpoints.up("md")} {
width: 400px;
margin-left: auto;
margin-right: auto;
}
`;

const PaperStyled = styled(Paper)`
margin-top: ${theme => theme.spacing.unit * 8}px;
display: flex;
flex-direction: column;
align-items: center;
padding: ${theme => theme.spacing.unit * 2}px ${theme =>
theme.spacing.unit * 3}px ${theme => theme.spacing.unit * 3}px;
}}
`;

const AvatarStyled = styled(Avatar)`
margin: ${theme => theme.spacing.unit}px;
background-color: ${theme => theme.palette.secondary.main};
`;

const Form = styled.form`
width: 100%;
margin-top: ${theme => theme.spacing.unit}px;
`;

const SubmitButtonStyled = styled(Button)`
margin-top: ${theme => theme.spacing.unit * 3}px;
`;

export { Base, PaperStyled, AvatarStyled, Form, SubmitButtonStyled };
3 changes: 3 additions & 0 deletions src/components/SignUp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import SignUp from "./SignUp";

export default SignUp;

0 comments on commit 73b1943

Please sign in to comment.