From 08b071bcaaae78f73186ec2629964aecb2809d5e Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 30 Jan 2021 01:04:32 +0800 Subject: [PATCH] pull out sidebar from the app page --- frontend/components/SideBar.js | 100 ++++++++++++++++++++++++++ frontend/pages/_app.tsx | 124 ++------------------------------- frontend/src/theme.js | 4 +- 3 files changed, 106 insertions(+), 122 deletions(-) create mode 100644 frontend/components/SideBar.js diff --git a/frontend/components/SideBar.js b/frontend/components/SideBar.js new file mode 100644 index 000000000..9b08e1c76 --- /dev/null +++ b/frontend/components/SideBar.js @@ -0,0 +1,100 @@ +import Drawer from "@material-ui/core/Drawer"; +import Divider from "@material-ui/core/Divider"; +import List from "@material-ui/core/List"; +import Link from "next/link"; +import ListItem from "@material-ui/core/ListItem"; +import ListItemIcon from "@material-ui/core/ListItemIcon"; +import DashboardIcon from "@material-ui/icons/Dashboard"; +import ListItemText from "@material-ui/core/ListItemText"; +import ListIcon from "@material-ui/icons/List"; +import TrendingUpIcon from "@material-ui/icons/TrendingUp"; +import React from "react"; +import {makeStyles} from "@material-ui/core/styles"; + +const drawerWidth = 260; + +const useStyles = makeStyles((theme) => ({ + root: { + // flexGrow: 1, + display: 'flex', + }, + content: { + flexGrow: 1, + height: '100vh', + overflow: 'auto', + }, + fixedHeight: { + height: 240, + }, + toolbar: { + paddingRight: 24, // keep right padding when drawer closed + }, + toolbarIcon: { + display: 'flex', + alignItems: 'center', + justifyContent: 'flex-end', + padding: '0 8px', + ...theme.mixins.toolbar, + }, + appBarSpacer: theme.mixins.toolbar, + drawerPaper: { + position: 'relative', + whiteSpace: 'nowrap', + width: drawerWidth, + transition: theme.transitions.create('width', { + easing: theme.transitions.easing.sharp, + duration: theme.transitions.duration.enteringScreen, + }), + }, +})); + + +export default function SideBar() { + const classes = useStyles(); + + return + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/frontend/pages/_app.tsx b/frontend/pages/_app.tsx index a2201dc53..120b63ee9 100644 --- a/frontend/pages/_app.tsx +++ b/frontend/pages/_app.tsx @@ -1,29 +1,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import Head from 'next/head'; -import Link from 'next/link'; import {makeStyles, ThemeProvider} from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; -import IconButton from '@material-ui/core/IconButton'; -import MenuIcon from '@material-ui/icons/Menu'; -import Drawer from '@material-ui/core/Drawer'; -import Divider from '@material-ui/core/Divider'; -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 DashboardIcon from '@material-ui/icons/Dashboard'; -import TrendingUpIcon from '@material-ui/icons/TrendingUp'; -import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; -import ListIcon from '@material-ui/icons/List'; - - -import clsx from "classnames"; +import SideBar from '../components/SideBar'; import CssBaseline from '@material-ui/core/CssBaseline'; import theme from '../src/theme'; @@ -65,54 +50,13 @@ const useStyles = makeStyles((theme) => ({ }, appBar: { zIndex: theme.zIndex.drawer + 1, - transition: theme.transitions.create(['width', 'margin'], { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.leavingScreen, - }), }, appBarSpacer: theme.mixins.toolbar, - appBarShift: { - marginLeft: drawerWidth, - width: `calc(100% - ${drawerWidth}px)`, - transition: theme.transitions.create(['width', 'margin'], { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.enteringScreen, - }), - }, - drawerPaper: { - position: 'relative', - whiteSpace: 'nowrap', - width: drawerWidth, - transition: theme.transitions.create('width', { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.enteringScreen, - }), - }, - drawerPaperClose: { - overflowX: 'hidden', - transition: theme.transitions.create('width', { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.leavingScreen, - }), - width: theme.spacing(7), - [theme.breakpoints.up('sm')]: { - width: theme.spacing(9), - }, - }, })); export default function MyApp(props) { const {Component, pageProps} = props; - const [open, setOpen] = React.useState(true); - - const handleDrawerOpen = () => { - setOpen(true); - }; - const handleDrawerClose = () => { - setOpen(false); - }; - const classes = useStyles(); React.useEffect(() => { @@ -132,22 +76,10 @@ export default function MyApp(props) { {/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */} +
- - + - - - - BBGO @@ -155,55 +87,7 @@ export default function MyApp(props) { - -
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
diff --git a/frontend/src/theme.js b/frontend/src/theme.js index 21af17c75..631d8279d 100644 --- a/frontend/src/theme.js +++ b/frontend/src/theme.js @@ -5,10 +5,10 @@ import { red } from '@material-ui/core/colors'; const theme = createMuiTheme({ palette: { primary: { - main: '#556cd6', + main: '#eb9534', }, secondary: { - main: '#19857b', + main: '#ccc0b1', }, error: { main: red.A400,