import { Divider, Drawer, List } from '@material-ui/core'; import { NavLink } from 'react-router-dom'; import classnames from 'classnames'; import PropTypes from 'prop-types'; import GitHubIcon from '@material-ui/icons/GitHub'; import LibraryBooksIcon from '@material-ui/icons/LibraryBooks'; import styles from './drawer.module.scss'; import { baseRoutes as routes } from './routes'; import { ReactComponent as LogoIcon } from '../../assets/icons/logo_wbg.svg'; const filterByFlags = flags => r => { if (r.flag && !flags[r.flag]) { return false; } return true; }; function getIcon(IconComponent) { if (IconComponent === 'c_github') { return ; } else if (IconComponent === 'library_books') { return ; } else { return ; } } function renderLink(link, toggleDrawer) { if (link.path) { return ( toggleDrawer()} key={link.path} to={link.path} className={classnames(styles.navigationLink)} activeClassName={classnames(styles.navigationLinkActive)} > {getIcon(link.icon)} {link.value} ); } else { return ( {getIcon(link.icon)} {link.value} ); } } export const DrawerMenu = ({ links = [], title = 'Unleash', flags = {}, open = false, toggleDrawer, }) => ( toggleDrawer()} >
{title}
{routes.filter(filterByFlags(flags)).map(item => ( toggleDrawer()} key={item.path} to={item.path} className={classnames(styles.navigationLink)} activeClassName={classnames( styles.navigationLinkActive )} > {getIcon(item.icon)} {item.title} ))} {links.map(l => renderLink(l, toggleDrawer))}
); DrawerMenu.propTypes = { links: PropTypes.array, title: PropTypes.string, flags: PropTypes.object, open: PropTypes.bool, toggleDrawer: PropTypes.func, };