import React from "react"; import { makeStyles, Theme, createStyles, useTheme, AppBar, Toolbar, IconButton, Typography, Drawer, Divider, List, ListItem, ListItemIcon, ListItemText, Tooltip, } from "@material-ui/core"; import Link from "next/link"; import MenuIcon from "@material-ui/icons/Menu"; import HomeIcon from "@material-ui/icons/Home"; import SettingsEthernetIcon from "@material-ui/icons/SettingsEthernet"; import SendIcon from "@material-ui/icons/Send"; import FolderIcon from "@material-ui/icons/Folder"; import ChevronLeftIcon from "@material-ui/icons/ChevronLeft"; import ChevronRightIcon from "@material-ui/icons/ChevronRight"; import clsx from "clsx"; export enum Page { Home, GetStarted, Projects, ProxySetup, ProxyLogs, Sender, } const drawerWidth = 240; const useStyles = makeStyles((theme: Theme) => createStyles({ root: { display: "flex", width: "100%", }, appBar: { zIndex: theme.zIndex.drawer + 1, transition: theme.transitions.create(["width", "margin"], { easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen, }), }, appBarShift: { marginLeft: drawerWidth, width: `calc(100% - ${drawerWidth}px)`, transition: theme.transitions.create(["width", "margin"], { easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.enteringScreen, }), }, menuButton: { marginRight: 28, }, hide: { display: "none", }, drawer: { width: drawerWidth, flexShrink: 0, whiteSpace: "nowrap", }, drawerOpen: { width: drawerWidth, transition: theme.transitions.create("width", { easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.enteringScreen, }), }, drawerClose: { transition: theme.transitions.create("width", { easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen, }), overflowX: "hidden", width: theme.spacing(7) + 1, [theme.breakpoints.up("sm")]: { width: theme.spacing(7) + 8, }, }, toolbar: { display: "flex", alignItems: "center", justifyContent: "flex-end", padding: theme.spacing(0, 1), // necessary for content to be below app bar ...theme.mixins.toolbar, }, content: { flexGrow: 1, padding: theme.spacing(3), }, listItem: { paddingLeft: 16, paddingRight: 16, [theme.breakpoints.up("sm")]: { paddingLeft: 20, paddingRight: 20, }, }, listItemIcon: { minWidth: 42, }, titleHighlight: { color: theme.palette.secondary.main, marginRight: 4, }, }) ); interface Props { children: React.ReactNode; title: string; page: Page; } export function Layout({ title, page, children }: Props): JSX.Element { const classes = useStyles(); const theme = useTheme(); const [open, setOpen] = React.useState(false); const handleDrawerOpen = () => { setOpen(true); }; const handleDrawerClose = () => { setOpen(false); }; return (