This repository was archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·192 lines (181 loc) · 4.63 KB
/
index.js
File metadata and controls
executable file
·192 lines (181 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import React from 'react';
import { Link as RouterLink } from 'react-router-dom';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import {
AppBar,
Box,
Hidden,
Toolbar,
Typography,
makeStyles
} from '@material-ui/core';
import Logo from 'src/components/Logo';
import Item from './Item';
import Account from './Account';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import CloseIcon from '@material-ui/icons/Close';
import Drawer from '@material-ui/core/Drawer';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import { HashLink as Link } from 'react-router-hash-link';
const useStyles = makeStyles(theme => ({
root: {
zIndex: theme.zIndex.drawer + 100,
backgroundColor: theme.palette.background.default,
paddingLeft: 70,
paddingRight: 70,
top: 'auto',
[theme.breakpoints.down('md')]: {
paddingLeft: 15,
paddingRight: 15
}
},
toolbar: {
minHeight: 64,
maxHeight: 64
},
menuButton: {
float: 'right',
color: '#000',
marginRight: '0px'
},
list: {
width: '100% !important',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
},
textStyle: {
textDecoration: 'none'
}
}));
function TopBar({ className, onMobileNavOpen, ...rest }) {
const classes = useStyles();
const [state, setState] = React.useState({
top: false,
left: false,
bottom: false,
right: false
});
const pathname = window.location.pathname;
const navItems = [
{ title: 'Campus Leaders', link: '/campusLeaders' },
{ title: 'Events', link: '/events' },
{ title: 'Courses', link: '/courses' }
// { title: 'Team', link: '/team' }
];
const list = () => (
<div
className={classes.list}
role="presentation"
onClick={toggleDrawer('right', false)}
onKeyDown={toggleDrawer('right', false)}
>
<List>
{navItems.map((item, index) => (
<ListItem button key={index}>
<Link
smooth
to={item.link}
variant="h5"
className={classes.textStyle}
>
<Typography variant="h4" color="textPrimary">
{item.title}
</Typography>
</Link>
</ListItem>
))}
</List>
</div>
);
const headerMoblie = () => (
<div>
<RouterLink
to="/"
style={{ position: 'absolute', left: '20px', top: '3%' }}
>
<Logo className={classes.logo} />
</RouterLink>
<Box ml={8}>
<IconButton
edge="end"
className={classes.menuButton}
aria-label="menu"
onClick={toggleDrawer('right', false)}
style={{ position: 'absolute', right: '15px', top: '1%' }}
>
<CloseIcon />
</IconButton>
</Box>
</div>
);
const toggleDrawer = (anchor, open) => event => {
if (
event.type === 'keydown' &&
(event.key === 'Tab' || event.key === 'Shift')
) {
return;
}
setState({ ...state, [anchor]: open });
};
return (
<AppBar className={clsx(classes.root, className)} {...rest}>
<Toolbar className={classes.toolbar}>
<RouterLink to="/">
<Logo className={classes.logo} />
</RouterLink>
<Hidden smDown>
<Box ml={2} flexGrow={1} />
{navItems.map((item, index) => (
<Item
key={index}
active={item.link === pathname}
title={item.title}
link={item.link}
/>
))}
<Box ml={2} flexGrow={0.05} />
<Box ml={2}>
<Account />
</Box>
<Box ml={2} flexGrow={0.05} />
</Hidden>
<Hidden mdUp>
<Box
display="flex"
flexDirection="row"
alignItems="center"
style={{ position: 'absolute', right: '0px' }}
>
<Account />
<IconButton
edge="end"
className={classes.menuButton}
aria-label="menu"
onClick={toggleDrawer('right', true)}
>
<MenuIcon />
</IconButton>
</Box>
<Drawer
width={'100%'}
anchor="right"
open={state['right']}
onClose={toggleDrawer('right', false)}
>
{headerMoblie()}
{list()}
</Drawer>
</Hidden>
</Toolbar>
</AppBar>
);
}
TopBar.propTypes = {
className: PropTypes.string,
onMobileNavOpen: PropTypes.func
};
export default TopBar;