Skip to content

Commit 6adeb72

Browse files
Merge pull request #184 from chiragmalik2612/main
Bootstrap Components to Material-UI (login, Signup)
2 parents e27fe2f + fbf3979 commit 6adeb72

File tree

3 files changed

+231
-141
lines changed

3 files changed

+231
-141
lines changed

frontend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"private": true,
55
"author": "SnapURL Team",
66
"dependencies": {
7-
"@emotion/react": "^11.11.1",
8-
"@emotion/styled": "^11.11.0",
7+
"@emotion/react": "^11.13.3",
8+
"@emotion/styled": "^11.13.0",
99
"@fortawesome/free-brands-svg-icons": "^6.4.2",
1010
"@fortawesome/react-fontawesome": "^0.2.0",
1111
"@mui/icons-material": "^5.14.12",
12-
"@mui/material": "^5.14.12",
12+
"@mui/material": "^5.16.7",
1313
"@testing-library/jest-dom": "^5.16.5",
1414
"@testing-library/react": "^13.4.0",
1515
"@testing-library/user-event": "^13.5.0",

frontend/src/components/Login.jsx

Lines changed: 94 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
import Button from 'react-bootstrap/Button';
2-
import Card from 'react-bootstrap/Card';
3-
import Form from 'react-bootstrap/Form';
4-
import Container from 'react-bootstrap/Container';
51
import React, { useEffect, useState, useContext } from 'react';
62
import { toast } from 'react-toastify';
73
import axios from 'axios';
84
import { useNavigate } from 'react-router-dom';
95
import { FaUserAlt, FaKey, FaSignInAlt } from 'react-icons/fa';
106
import UserContext from '../context/UserContext';
7+
import {
8+
Container,
9+
Box,
10+
Card,
11+
CardContent,
12+
CardHeader,
13+
CardActions,
14+
Button,
15+
TextField,
16+
Typography,
17+
Link,
18+
Divider,
19+
} from '@mui/material';
1120
import '../App.css';
1221
import './Footer.css';
1322

@@ -62,7 +71,6 @@ function Login() {
6271
user: { name },
6372
} = response.data;
6473

65-
// set token and logged-in user's name in local storage
6674
localStorage.setItem('token', token);
6775
localStorage.setItem('name', name);
6876
context.setUser({ token: token });
@@ -97,92 +105,119 @@ function Login() {
97105

98106
return (
99107
<Container
100-
className="d-flex align-items-center justify-content-center"
101-
style={{ minHeight: '90vh' }}
108+
sx={{
109+
display: 'flex',
110+
alignItems: 'center',
111+
justifyContent: 'center',
112+
minHeight: '90vh',
113+
}}
102114
>
103-
<div className="w-100" style={{ maxWidth: '400px' }}>
115+
<Box sx={{ maxWidth: '400px', width: '100%' }}>
104116
<Card>
105-
<Card.Header style={{ backgroundColor: '#4B3F6B' }}>
106-
{' '}
107-
<h4 style={{ backgroundColor: '#4B3F6B' }}>Login</h4>{' '}
108-
</Card.Header>
109-
<Card.Body>
110-
<Form onSubmit={handleSubmit}>
111-
<Form.Group className="mb-3" controlId="formBasicEmail">
112-
<Form.Label
113-
style={{ display: 'flex', gap: '5px', alignItems: 'center' }}
117+
<CardHeader
118+
sx={{ backgroundColor: '#4B3F6B', color: 'white' }}
119+
title={<Typography variant="h5">Login</Typography>}
120+
/>
121+
<CardContent>
122+
<Box component="form" onSubmit={handleSubmit}>
123+
<Box sx={{ mb: 3 }}>
124+
<Typography
125+
component="label"
126+
sx={{
127+
display: 'flex',
128+
gap: '5px',
129+
alignItems: 'center',
130+
marginBottom: '7px',
131+
fontWeight: '600',
132+
}}
114133
>
115134
<FaUserAlt /> Email address
116-
</Form.Label>
117-
<Form.Control
135+
</Typography>
136+
<TextField
137+
fullWidth
138+
size="small"
118139
type="email"
119140
placeholder="Enter email"
120141
onChange={(e) => setEmail(e.target.value)}
121-
aria-required={true}
142+
required
122143
/>
123-
<Form.Text className="text-muted">
144+
<Typography variant="caption" color="textSecondary">
124145
We'll never share your email with anyone else.
125-
</Form.Text>
126-
</Form.Group>
127-
<Form.Group className="mb-3" controlId="formBasicPassword">
128-
<Form.Label
129-
style={{ display: 'flex', gap: '5px', alignItems: 'center' }}
146+
</Typography>
147+
</Box>
148+
149+
<Box sx={{ mb: 3 }}>
150+
<Typography
151+
component="label"
152+
sx={{
153+
display: 'flex',
154+
gap: '5px',
155+
alignItems: 'center',
156+
marginBottom: '7px',
157+
fontWeight: '600',
158+
}}
130159
>
131160
<FaKey /> Password
132-
</Form.Label>
133-
<Form.Control
161+
</Typography>
162+
<TextField
163+
fullWidth
164+
size="small"
134165
type="password"
135166
placeholder="Password"
136167
onChange={(e) => setPassword(e.target.value)}
137-
aria-required={true}
168+
required
138169
/>
139-
<a
140-
onClick={() => {
141-
navigate('/forgot-password');
142-
}}
143-
style={{
170+
<Link
171+
onClick={() => navigate('/forgot-password')}
172+
sx={{
144173
textDecoration: 'none',
145174
color: '#4B3F6B',
146175
cursor: 'pointer',
176+
fontSize: '14px',
147177
}}
148178
>
149-
{' '}
150-
<span style={{ fontSize: '14px', color: '#4B3F6B' }}>
151-
Forgot password
152-
</span>{' '}
153-
</a>{' '}
154-
</Form.Group>
179+
Forgot password
180+
</Link>
181+
</Box>
155182
<Button
156-
className={'w-100'}
157-
variant="info"
183+
fullWidth
184+
variant="contained"
158185
type="submit"
159-
style={{ backgroundColor: '#4B3F6B', color: 'white' }}
186+
sx={{
187+
backgroundColor: '#4B3F6B',
188+
color: 'white',
189+
borderRadius: '20px',
190+
}}
191+
startIcon={<FaSignInAlt />}
160192
>
161-
<FaSignInAlt style={{ marginRight: '0.3rem' }} />
162193
LOGIN
163194
</Button>
164-
</Form>
165-
</Card.Body>
166-
<Card.Footer
167-
className="text-muted"
168-
style={{ display: 'flex', justifyContent: 'space-between' }}
195+
</Box>
196+
</CardContent>
197+
<Divider sx={{ backgroundColor: 'black' }} />
198+
<CardActions
199+
sx={{
200+
display: 'flex',
201+
justifyContent: 'space-between',
202+
padding: '14px',
203+
}}
169204
>
170-
Don't Have an Account?{' '}
171-
<a
172-
style={{
205+
<Typography variant="body1" sx={{ color: 'grey' }}>
206+
Don't Have an Account?
207+
</Typography>
208+
<Link
209+
onClick={() => navigate('/signup')}
210+
sx={{
173211
textDecoration: 'none',
174212
color: '#4B3F6B',
175213
cursor: 'pointer',
176214
}}
177-
onClick={() => {
178-
navigate('/signup');
179-
}}
180215
>
181-
<span>Click Here to Signup</span>
182-
</a>
183-
</Card.Footer>
216+
Click Here to Signup
217+
</Link>
218+
</CardActions>
184219
</Card>
185-
</div>
220+
</Box>
186221
</Container>
187222
);
188223
}

0 commit comments

Comments
 (0)