Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Commit 4826455

Browse files
fixed login button covering the cfc title and home-view hero page (#102)
* fixed login button covering the whole cfc title and home-view hero page length * revision 1: Add login to drawer
1 parent 0ebe2e2 commit 4826455

File tree

5 files changed

+96
-62
lines changed

5 files changed

+96
-62
lines changed

src/components/Hero/HeroWithLogo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ function Hero({
6161
firstComponent,
6262
secondComponent,
6363
imageUrl,
64+
className,
6465
...rest
6566
}) {
6667
const classes = useStyles();
6768

6869
return (
69-
<div className={clsx(classes.root)} {...rest}>
70+
<div className={clsx(classes.root, className)} {...rest}>
7071
<Container maxWidth="lg">
7172
<Grid container spacing={3}>
7273
<Grid item xs={12} md={6}>

src/layouts/MainLayout/TopBar/Account.js

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import React from 'react';
22
import { useSelector } from 'react-redux';
33
import { useDispatch } from 'react-redux';
44
import PersonIcon from '@material-ui/icons/Person';
5-
65
import {
76
Typography,
8-
Dialog,
9-
DialogContent,
107
Button,
118
Box,
129
Avatar,
@@ -16,8 +13,6 @@ import {
1613
CircularProgress,
1714
makeStyles
1815
} from '@material-ui/core';
19-
import authService from 'src/services/authService';
20-
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
2116
import { login, dismissLogin, logout } from 'src/actions/accountActions';
2217

2318
const useStyles = makeStyles(theme => ({
@@ -28,7 +23,6 @@ const useStyles = makeStyles(theme => ({
2823

2924
function Account() {
3025
const user = useSelector(state => state.account.user);
31-
const loginFlag = useSelector(state => state.account.login);
3226
const [anchorEl, setAnchorEl] = React.useState(null);
3327
const dispatch = useDispatch();
3428
const classes = useStyles();
@@ -39,10 +33,6 @@ function Account() {
3933
dispatch(dismissLogin());
4034
};
4135

42-
const handleClose = () => {
43-
dispatch(dismissLogin());
44-
};
45-
4636
const handleLoginOpen = () => {
4737
dispatch(login());
4838
};
@@ -143,53 +133,6 @@ function Account() {
143133
)}
144134
</Button>
145135
)}
146-
147-
<Dialog
148-
open={!user && !!loginFlag}
149-
onClose={handleClose}
150-
aria-labelledby="form-dialog-title"
151-
>
152-
<DialogContent
153-
style={{
154-
background: '#E2E9FF'
155-
}}
156-
>
157-
<Box
158-
display="flex"
159-
flexDirection="column"
160-
alignItems="center"
161-
justifyContent="center"
162-
mt={2}
163-
mb={2}
164-
>
165-
<Typography
166-
variant="h3"
167-
style={{
168-
marginBottom: '8px'
169-
}}
170-
>
171-
Login / Sign Up
172-
</Typography>
173-
174-
<Typography variant="body2">Explore learning with</Typography>
175-
176-
<Typography
177-
variant="body2"
178-
style={{
179-
marginBottom: '12px'
180-
}}
181-
>
182-
Open Source
183-
</Typography>
184-
185-
<StyledFirebaseAuth
186-
uiConfig={authService.uiConfig}
187-
firebaseAuth={authService.firebase.auth()}
188-
/>
189-
</Box>
190-
</DialogContent>
191-
</Dialog>
192-
193136
<Menu
194137
id="menu-appbar"
195138
anchorEl={anchorEl}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React from 'react';
2+
import { useSelector } from 'react-redux';
3+
import { useDispatch } from 'react-redux';
4+
5+
import { Typography, Dialog, DialogContent, Box } from '@material-ui/core';
6+
import authService from 'src/services/authService';
7+
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
8+
import { dismissLogin } from 'src/actions/accountActions';
9+
10+
function LoginDialog() {
11+
const user = useSelector(state => state.account.user);
12+
const loginFlag = useSelector(state => state.account.login);
13+
const dispatch = useDispatch();
14+
15+
const handleClose = () => {
16+
dispatch(dismissLogin());
17+
};
18+
19+
return (
20+
<Dialog
21+
open={!user && !!loginFlag}
22+
onClose={handleClose}
23+
aria-labelledby="form-dialog-title"
24+
>
25+
<DialogContent
26+
style={{
27+
background: '#E2E9FF'
28+
}}
29+
>
30+
<Box
31+
display="flex"
32+
flexDirection="column"
33+
alignItems="center"
34+
justifyContent="center"
35+
mt={2}
36+
mb={2}
37+
>
38+
<Typography
39+
variant="h3"
40+
style={{
41+
marginBottom: '8px'
42+
}}
43+
>
44+
Login / Sign Up
45+
</Typography>
46+
47+
<Typography variant="body2">Explore learning with</Typography>
48+
49+
<Typography
50+
variant="body2"
51+
style={{
52+
marginBottom: '12px'
53+
}}
54+
>
55+
Open Source
56+
</Typography>
57+
58+
<StyledFirebaseAuth
59+
uiConfig={authService.uiConfig}
60+
firebaseAuth={authService.firebase.auth()}
61+
/>
62+
</Box>
63+
</DialogContent>
64+
</Dialog>
65+
);
66+
}
67+
68+
export default LoginDialog;

src/layouts/MainLayout/TopBar/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import Drawer from '@material-ui/core/Drawer';
2020
import List from '@material-ui/core/List';
2121
import ListItem from '@material-ui/core/ListItem';
2222
import { HashLink as Link } from 'react-router-hash-link';
23+
import LoginDialog from './LoginDialog';
24+
import { useSelector } from 'react-redux';
2325

2426
const useStyles = makeStyles(theme => ({
2527
root: {
@@ -55,6 +57,7 @@ const useStyles = makeStyles(theme => ({
5557

5658
function TopBar({ className, onMobileNavOpen, ...rest }) {
5759
const classes = useStyles();
60+
const user = useSelector(state => state.account.user);
5861
const [state, setState] = React.useState({
5962
top: false,
6063
left: false,
@@ -93,6 +96,13 @@ function TopBar({ className, onMobileNavOpen, ...rest }) {
9396
</Link>
9497
</ListItem>
9598
))}
99+
{!user ? (
100+
<ListItem>
101+
<Account />
102+
</ListItem>
103+
) : (
104+
<div />
105+
)}
96106
</List>
97107
</div>
98108
);
@@ -146,6 +156,7 @@ function TopBar({ className, onMobileNavOpen, ...rest }) {
146156
))}
147157
<Box ml={2} flexGrow={0.05} />
148158
<Box ml={2}>
159+
<LoginDialog />
149160
<Account />
150161
</Box>
151162
<Box ml={2} flexGrow={0.05} />
@@ -157,8 +168,8 @@ function TopBar({ className, onMobileNavOpen, ...rest }) {
157168
alignItems="center"
158169
style={{ position: 'absolute', right: '0px' }}
159170
>
160-
<Account />
161-
171+
<LoginDialog />
172+
{user ? <Account /> : <div />}
162173
<IconButton
163174
edge="end"
164175
className={classes.menuButton}

src/views/pages/HomeView/Hero.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4-
import { Typography } from '@material-ui/core';
4+
import { makeStyles, Typography } from '@material-ui/core';
55
import PlayArrowIcon from '@material-ui/icons/PlayArrow';
66

77
import HeroWithLogo from '../../../components/Hero/HeroWithLogo';
88
import ButtonComponent from 'src/components/Button/ButtonComponent';
99

10+
const useStyles = makeStyles(theme => ({
11+
root: {},
12+
hero: {
13+
height: '420px',
14+
[theme.breakpoints.down('md')]: {
15+
height: '100%'
16+
}
17+
}
18+
}));
19+
1020
function Hero({ className, ...rest }) {
21+
const classes = useStyles();
1122
return (
1223
<div className={className} {...rest}>
1324
<HeroWithLogo
14-
style={{ height: '420px' }}
25+
className={classes.hero}
1526
title="Learn for Cause"
1627
title2="Code for Cause"
1728
imageUrl="/static/home/codeforcause.svg"

0 commit comments

Comments
 (0)