import { graphql, useStaticQuery } from "gatsby"; import * as React from "react"; import { AppBar, Toolbar, IconButton, Button, Typography, Drawer, List, Divider, ListItem, ListItemText, Hidden, } from "@material-ui/core"; import { Menu as MenuIcon } from "@material-ui/icons"; import { makeStyles } from "@material-ui/core/styles"; const useStyles = makeStyles((theme) => ({ root: { flexGrow: 1, }, bar: { backgroundColor: "#66595c", }, menuButton: { marginRight: theme.spacing(2), }, title: { flexGrow: 1, }, })); interface NavQuery { site: { siteMetadata: { title: string; nav: { name: string; url: string; }[]; }; }; allProvidersYaml: { edges: { node: { id: string; title: string; modal: string; }; }[]; }; } const Nav = (): React.ReactElement => { const classes = useStyles({}); const [state, setState] = React.useState({ drawerOpen: false, }); const data = useStaticQuery(graphql` query NavQuery { site { siteMetadata { title nav { name url } } } allProvidersYaml { edges { node { id title modal } } } } `); // Disabling this lint rule for now, it does raise a good point for future refactoring though. // TODO: refactor // eslint-disable-next-line unicorn/consistent-function-scoping const toggleDrawer = (open: boolean) => ( event: React.KeyboardEvent | React.MouseEvent ): void => { if ( event.type === "keydown" && ((event as React.KeyboardEvent).key === "Tab" || (event as React.KeyboardEvent).key === "Shift") ) { return; } setState({ ...state, drawerOpen: open, }); }; return ( <>
{data.site.siteMetadata.nav.map((link) => ( ))} {data.allProvidersYaml.edges.map(({ node }) => ( ))}
); }; export default Nav;