-
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 #186 from cisagov/RSC-Nav
Update RSC Dashboard Navigation
- Loading branch information
Showing
14 changed files
with
442 additions
and
70 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React from 'react'; | ||
import { Divider, useScrollTrigger } from '@mui/material'; | ||
import Box from '@mui/material/Box'; | ||
import Fab from '@mui/material/Fab'; | ||
import Menu from '@mui/material/Menu'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import NavigationIcon from '@mui/icons-material/Navigation'; | ||
import Zoom from '@mui/material/Zoom'; | ||
import { HashLink } from 'react-router-hash-link'; | ||
|
||
interface Props { | ||
categories: Category[]; | ||
} | ||
|
||
export interface Category { | ||
name: string; | ||
} | ||
export const FloatingNav: React.FC<Props> = ({ categories }) => { | ||
const trigger = useScrollTrigger({ | ||
threshold: 100 | ||
}); | ||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); | ||
const open = Boolean(anchorEl); | ||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Zoom in={trigger}> | ||
<Box | ||
role="presentation" | ||
sx={{ | ||
position: 'fixed', | ||
bottom: 80, | ||
right: 32, | ||
zIndex: 1 | ||
}} | ||
> | ||
<Fab | ||
onClick={handleClick} | ||
color="primary" | ||
size="small" | ||
aria-label="Scroll back to top" | ||
style={{ outline: 'none' }} | ||
> | ||
<NavigationIcon fontSize="medium" /> | ||
</Fab> | ||
</Box> | ||
</Zoom> | ||
<Menu | ||
id="basic-menu" | ||
anchorEl={anchorEl} | ||
open={open} | ||
onClose={handleClose} | ||
anchorOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'left' | ||
}} | ||
transformOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'right' | ||
}} | ||
MenuListProps={{ | ||
'aria-labelledby': 'basic-button' | ||
}} | ||
> | ||
{categories.map((category, index) => ( | ||
<div key={index}> | ||
<MenuItem onClick={handleClose}> | ||
<HashLink | ||
style={{ | ||
textDecoration: 'none', | ||
color: 'black', | ||
outline: 'none' | ||
}} | ||
to={`#${category.name}`} | ||
> | ||
{category.name} | ||
</HashLink> | ||
</MenuItem> | ||
<Divider /> | ||
</div> | ||
))} | ||
</Menu> | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { Accordion, AccordionDetails, AccordionSummary } from '@mui/material'; | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; | ||
import { HashLink } from 'react-router-hash-link'; | ||
|
||
interface Props { | ||
categories: Category[]; | ||
} | ||
|
||
export interface Category { | ||
name: string; | ||
} | ||
|
||
export const RSCAccordionNav: React.FC<Props> = ({ categories }) => { | ||
return ( | ||
<Accordion> | ||
<AccordionSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-controls="panel1a-content" | ||
id="panel1a-header" | ||
style={{ outline: 'none' }} | ||
> | ||
{' '} | ||
Categories | ||
</AccordionSummary> | ||
{categories.map((category, index) => ( | ||
<AccordionDetails key={index}> | ||
<HashLink | ||
style={{ textDecoration: 'none', outline: 'none', color: 'black' }} | ||
to={`#${category.name}`} | ||
> | ||
{category.name} | ||
</HashLink> | ||
</AccordionDetails> | ||
))} | ||
</Accordion> | ||
); | ||
}; |
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
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
Oops, something went wrong.