import React from 'react'; import PropTypes from 'prop-types'; import AppBar from '@material-ui/core/AppBar'; import CssBaseline from '@material-ui/core/CssBaseline'; import Divider from '@material-ui/core/Divider'; import Drawer from '@material-ui/core/Drawer'; import Hidden from '@material-ui/core/Hidden'; import IconButton from '@material-ui/core/IconButton'; import InboxIcon from '@material-ui/icons/MoveToInbox'; import List from '@material-ui/core/List'; import ListItem from '@material-ui/core/ListItem'; import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemText from '@material-ui/core/ListItemText'; import MailIcon from '@material-ui/icons/Mail'; import MenuIcon from '@material-ui/icons/Menu'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import { makeStyles, useTheme } from '@material-ui/core/styles'; import MkFormPage from './MkFormPage'; import { Route, Router, Switch } from 'react-router-dom'; import WelcomPage from './WelcomPage'; import { createBrowserHistory } from 'history'; import MkTablePage from './MkTablePage'; const browserHistory = createBrowserHistory(); const drawerWidth = 240; const useStyles = makeStyles((theme) => ({ root: { display: 'flex', }, drawer: { [theme.breakpoints.up('sm')]: { width: drawerWidth, flexShrink: 0, }, }, appBar: { [theme.breakpoints.up('sm')]: { width: `calc(100% - ${drawerWidth}px)`, marginLeft: drawerWidth, }, }, menuButton: { marginRight: theme.spacing(2), [theme.breakpoints.up('sm')]: { display: 'none', }, }, // necessary for content to be below app bar toolbar: theme.mixins.toolbar, drawerPaper: { width: drawerWidth, }, content: { flexGrow: 1, padding: theme.spacing(3), }, })); function ResponsiveDrawer(props) { const { window } = props; const classes = useStyles(); const theme = useTheme(); const [mobileOpen, setMobileOpen] = React.useState(false); const [menuName, setMenuName] = React.useState(''); const handleDrawerToggle = () => { setMobileOpen(!mobileOpen); }; const handleOnClick = (path) => { setMenuName(path); browserHistory.push(path); } const menus = [ {name: 'MkForm', path:'MkForm'}, {name: 'MkTable', path:'MkTable'} ] const drawer = (
Mokkon
{menus.map((menu, index) => ( handleOnClick(menu.path)}> ))}
); const container = window !== undefined ? () => window().document.body : undefined; return (
{menuName}
); } ResponsiveDrawer.propTypes = { /** * Injected by the documentation to work in an iframe. * You won't need it on your project. */ window: PropTypes.func, }; export default ResponsiveDrawer;