Skip to content

Commit

Permalink
style sign up and remove avatar code
Browse files Browse the repository at this point in the history
  • Loading branch information
mykovasyl committed Mar 29, 2023
1 parent 3af24f8 commit c21b17e
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 33 deletions.
99 changes: 66 additions & 33 deletions client/src/components/LogIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ import React, { useContext, useState } from "react";
import { useNavigate } from "react-router-dom";
import { UserContext } from "./App";
import Button from "@mui/material/Button";
import CssBaseline from "@mui/material/CssBaseline";
import TextField from "@mui/material/TextField";
import FormControlLabel from "@mui/material/FormControlLabel";
import Checkbox from "@mui/material/Checkbox";
import Link from "@mui/material/Link";
import Grid from "@mui/material/Grid";
import Box from "@mui/material/Box";
import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
import Typography from "@mui/material/Typography";
import Container from "@mui/material/Container";
import { createTheme, ThemeProvider } from "@mui/material/styles";

function LogIn() {
const [login, setLogin] = useState({
username: "",
password: "",
});
const theme = createTheme();
const { setCurrentUser } = useContext(UserContext);
const navigate = useNavigate();

Expand All @@ -34,39 +46,60 @@ function LogIn() {
}

return (
<>
<h2
style={{
border: ".5px solid grey",
marginBottom: "24px",
borderRadius: "8px",
padding: "8px",
}}
>
Log in:
</h2>
<form onSubmit={handleSubmit}>
<p>Username:</p>
<input
type='text'
name='username'
value={login.username}
onChange={handleInputChange}
/>

<p>Password:</p>
<input
type='password'
name='password'
value={login.password}
onChange={handleInputChange}
/>

<Button type='submit' variant='contained' style={{ margin: "16px" }}>
Log in!
</Button>
</form>
</>
<ThemeProvider theme={theme}>
<Container component='main' maxWidth='xs'>
<CssBaseline />
<Box
sx={{
marginTop: 8,
display: "flex",
flexDirection: "column",
alignItems: "center",
}}
>
<Typography component='h1' variant='h5'>
Sign in
</Typography>
<Box
component='form'
onSubmit={handleSubmit}
noValidate
sx={{ mt: 1 }}
>
<TextField
margin='normal'
required
fullWidth
label='Username'
name='username'
autoComplete='username'
value={login.username}
onChange={handleInputChange}
autoFocus
/>
<TextField
margin='normal'
required
fullWidth
name='password'
label='Password'
type='password'
value={login.password}
onChange={handleInputChange}
autoComplete='current-password'
/>
<Button
type='submit'
fullWidth
variant='contained'
sx={{ mt: 3, mb: 2 }}
>
Sign In
</Button>
</Box>
</Box>
</Container>
</ThemeProvider>
);
}

Expand Down
119 changes: 119 additions & 0 deletions client/src/components/placeholder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import * as React from "react";
import Avatar from "@mui/material/Avatar";
import CssBaseline from "@mui/material/CssBaseline";
import TextField from "@mui/material/TextField";
import FormControlLabel from "@mui/material/FormControlLabel";
import Checkbox from "@mui/material/Checkbox";
import Link from "@mui/material/Link";
import Grid from "@mui/material/Grid";
import Box from "@mui/material/Box";
import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
import Typography from "@mui/material/Typography";
import Container from "@mui/material/Container";
import { createTheme, ThemeProvider } from "@mui/material/styles";

function Copyright(props) {
return (
<Typography
variant='body2'
color='text.secondary'
align='center'
{...props}
>
{"Copyright © "}
<Link color='inherit' href='https://mui.com/'>
Your Website
</Link>{" "}
{new Date().getFullYear()}
{"."}
</Typography>
);
}

const theme = createTheme();

export default function SignIn() {
const handleSubmit = (event) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get("email"),
password: data.get("password"),
});
};

return (
<ThemeProvider theme={theme}>
<Container component='main' maxWidth='xs'>
<CssBaseline />
<Box
sx={{
marginTop: 8,
display: "flex",
flexDirection: "column",
alignItems: "center",
}}
>
<Avatar sx={{ m: 1, bgcolor: "secondary.main" }}>
<LockOutlinedIcon />
</Avatar>
<Typography component='h1' variant='h5'>
Sign in
</Typography>
<Box
component='form'
onSubmit={handleSubmit}
noValidate
sx={{ mt: 1 }}
>
<TextField
margin='normal'
required
fullWidth
id='email'
label='Email Address'
name='email'
autoComplete='email'
autoFocus
/>
<TextField
margin='normal'
required
fullWidth
name='password'
label='Password'
type='password'
id='password'
autoComplete='current-password'
/>
<FormControlLabel
control={<Checkbox value='remember' color='primary' />}
label='Remember me'
/>
<Button
type='submit'
fullWidth
variant='contained'
sx={{ mt: 3, mb: 2 }}
>
Sign In
</Button>
<Grid container>
<Grid item xs>
<Link href='#' variant='body2'>
Forgot password?
</Link>
</Grid>
<Grid item>
<Link href='#' variant='body2'>
{"Don't have an account? Sign Up"}
</Link>
</Grid>
</Grid>
</Box>
</Box>
<Copyright sx={{ mt: 8, mb: 4 }} />
</Container>
</ThemeProvider>
);
}

0 comments on commit c21b17e

Please sign in to comment.