Files
suwayomi-material-you-webui/src/components/TemporaryDrawer.tsx

63 lines
2.1 KiB
TypeScript
Raw Normal View History

/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
2021-01-26 23:32:12 +03:30
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
2020-12-24 16:50:50 +01:00
import React from 'react';
2021-09-09 17:51:22 +04:30
import makeStyles from '@mui/styles/makeStyles';
import Drawer from '@mui/material/Drawer';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
2020-12-24 16:50:50 +01:00
import { Link } from 'react-router-dom';
const useStyles = makeStyles({
list: {
width: 250,
},
});
interface IProps {
drawerOpen: boolean
2020-12-25 06:36:34 +03:30
2021-05-15 17:18:57 +04:30
setDrawerOpen: React.Dispatch<React.SetStateAction<boolean>>
navBarItems: Array<NavbarItem>
2020-12-24 16:50:50 +01:00
}
export default function TemporaryDrawer({ drawerOpen, setDrawerOpen, navBarItems }: IProps) {
2020-12-24 16:50:50 +01:00
const classes = useStyles();
return (
<div>
<Drawer
open={drawerOpen}
anchor="left"
onClose={() => setDrawerOpen(false)}
>
2021-03-18 21:46:24 +03:30
<div
className={classes.list}
role="presentation"
onClick={() => setDrawerOpen(false)}
onKeyDown={() => setDrawerOpen(false)}
>
<List>
{navBarItems.map((({ path, title, IconComponent }: NavbarItem) => (
<Link to={path} style={{ color: 'inherit', textDecoration: 'none' }}>
<ListItem button key={title}>
<ListItemIcon>
<IconComponent />
</ListItemIcon>
<ListItemText primary={title} />
</ListItem>
</Link>
)))}
2021-03-18 21:46:24 +03:30
</List>
</div>
2020-12-24 16:50:50 +01:00
</Drawer>
</div>
);
}