-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from cisagov/RSC-Dashboard
Optimizations for ReadySetCyber Header, Dashboard, and Assessment
- Loading branch information
Showing
5 changed files
with
246 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,189 @@ | ||
import React from 'react'; | ||
import { AppBar } from '@mui/material'; | ||
import { Toolbar } from '@mui/material'; | ||
import { Typography } from '@mui/material'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { useAuthContext } from 'context'; | ||
import { | ||
AppBar, | ||
Toolbar, | ||
Container, | ||
Box, | ||
Typography, | ||
IconButton, | ||
Menu, | ||
MenuItem, | ||
Tooltip | ||
} from '@mui/material'; | ||
import AccountCircle from '@mui/icons-material/AccountCircle'; | ||
import MenuIcon from '@mui/icons-material/Menu'; | ||
import RSCLogo from 'components/ReadySetCyber/assets/ReadySetCyberLogo.png'; | ||
|
||
export const RSCHeader: React.FC = () => { | ||
const history = useHistory(); | ||
const handleClick = () => { | ||
const handleNavHome = () => { | ||
history.push('/readysetcyber'); | ||
}; | ||
const { logout, user } = useAuthContext(); | ||
|
||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); | ||
const [anchorElNav, setAnchorElNav] = React.useState<null | HTMLElement>( | ||
null | ||
); | ||
|
||
const handleOpenNavMenu = (event: React.MouseEvent<HTMLElement>) => { | ||
setAnchorElNav(event.currentTarget); | ||
}; | ||
|
||
const handleMenu = (event: React.MouseEvent<HTMLElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleCloseNavMenu = () => { | ||
setAnchorElNav(null); | ||
}; | ||
|
||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
return ( | ||
<AppBar position="static"> | ||
<Toolbar> | ||
<Typography variant="h6" onClick={handleClick}> | ||
Ready Set Cyber | ||
</Typography> | ||
</Toolbar> | ||
</AppBar> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<AppBar position="static" sx={{ bgcolor: 'white' }}> | ||
<Container maxWidth="xl"> | ||
<Toolbar disableGutters> | ||
<Tooltip title="Go to Ready Set Cyber" arrow> | ||
<IconButton | ||
onClick={handleNavHome} | ||
sx={{ display: { xs: 'none', md: 'flex' }, mr: 1 }} | ||
style={{ backgroundColor: 'white', outline: 'none' }} | ||
disableFocusRipple | ||
> | ||
<img | ||
src={RSCLogo} | ||
alt="Ready Set Cyber Logo" | ||
style={{ | ||
width: '4em', | ||
height: '2em' | ||
}} | ||
/> | ||
</IconButton> | ||
</Tooltip> | ||
<Typography | ||
variant="h6" | ||
component="div" | ||
sx={{ | ||
flexGrow: 1, | ||
color: '#07648D', | ||
display: { xs: 'none', md: 'flex' }, | ||
mr: 2 | ||
}} | ||
> | ||
Dashboard | ||
</Typography> | ||
<Box sx={{ flexGrow: 1, display: { xs: 'flex', md: 'none' } }}> | ||
<Tooltip title="Go to Ready Set Cyber" arrow> | ||
<IconButton | ||
onClick={handleNavHome} | ||
sx={{ display: { xs: 'flex', md: 'none' }, mr: 0 }} | ||
style={{ backgroundColor: 'white', outline: 'none' }} | ||
> | ||
<img | ||
src={RSCLogo} | ||
alt="Ready Set Cyber Logo" | ||
style={{ | ||
width: '4em', | ||
height: '2em' | ||
}} | ||
/> | ||
</IconButton> | ||
</Tooltip> | ||
</Box> | ||
{user && ( | ||
<> | ||
<IconButton | ||
size="large" | ||
aria-label="nav menu" | ||
aria-controls="menu-navbar" | ||
aria-haspopup="true" | ||
color="primary" | ||
onClick={handleOpenNavMenu} | ||
style={{ outline: 'none' }} | ||
sx={{ display: { xs: 'block', md: 'none' } }} | ||
> | ||
<MenuIcon /> | ||
</IconButton> | ||
<Menu | ||
id="menu-appbar" | ||
anchorEl={anchorElNav} | ||
anchorOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}} | ||
keepMounted | ||
transformOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}} | ||
open={Boolean(anchorElNav)} | ||
onClose={handleCloseNavMenu} | ||
sx={{ display: { xs: 'block', md: 'none' } }} | ||
> | ||
<MenuItem style={{ outline: 'none' }}> | ||
{' '} | ||
Welcome, user | ||
</MenuItem> | ||
<MenuItem style={{ outline: 'none' }} onClick={handleNavHome}> | ||
Dashboard | ||
</MenuItem> | ||
<MenuItem style={{ outline: 'none' }}> | ||
{' '} | ||
Take Questionnaire Again{' '} | ||
</MenuItem> | ||
<MenuItem style={{ outline: 'none' }} onClick={logout}> | ||
Logout | ||
</MenuItem> | ||
</Menu> | ||
</> | ||
)} | ||
{user && ( | ||
<Box sx={{ flexGrow: 0, display: { xs: 'none', md: 'flex' } }}> | ||
<Tooltip title="Open Menu" arrow> | ||
<IconButton | ||
sx={{ p: 0 }} | ||
size="large" | ||
aria-label="account of current user" | ||
aria-controls="menu-appbar" | ||
aria-haspopup="true" | ||
color="primary" | ||
onClick={handleMenu} | ||
style={{ outline: 'none' }} | ||
> | ||
<AccountCircle /> | ||
</IconButton> | ||
</Tooltip> | ||
<Menu | ||
sx={{ marginTop: '40px' }} | ||
id="menu-appbar" | ||
anchorEl={anchorEl} | ||
anchorOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}} | ||
keepMounted | ||
transformOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}} | ||
open={Boolean(anchorEl)} | ||
onClose={handleClose} | ||
> | ||
<MenuItem style={{ outline: 'none' }} onClick={logout}> | ||
Logout | ||
</MenuItem> | ||
</Menu> | ||
</Box> | ||
)} | ||
</Toolbar> | ||
</Container> | ||
</AppBar> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.