11import React , { useState } from 'react'
22import { makeStyles } from '@material-ui/core/styles' ;
3- import Drawer from '@material-ui/core/Drawer' ;
3+
4+ import Paper from '@material-ui/core/Paper'
45
56import IconButton from '@material-ui/core/IconButton'
6- import Toolbar from '@material-ui/core/Toolbar' ;
7+
78import List from '@material-ui/core/List' ;
89
910import ListItem from '@material-ui/core/ListItem' ;
@@ -23,41 +24,51 @@ import {
2324
2425
2526const drawerOpenWidth = 200 ;
26- const drawerCloseWidth = 54 ;
27+ const drawerCloseWidth = 48 ;
2728
28- const drawerCss = ( entering , transitions , palette ) => ( {
29+ const drawerCss = ( entering , transitions , palette , spacing ) => ( {
2930 overflow : 'hidden' ,
31+ marginTop : spacing ( 1 ) ,
32+ marginBottom : spacing ( 1 ) ,
33+ marginLeft : spacing ( 1 ) ,
3034 width : props => props . width ,
3135 flexShrink : 0 ,
3236 borderRight : 'none' ,
37+ position : 'relative' ,
3338 transition : transitions . create ( 'width' , {
3439 easing : transitions . easing . sharp ,
3540 duration : entering ? transitions . duration . enteringScreen : transitions . duration . leavingScreen ,
3641 } )
3742} )
3843
39- const useStyles = makeStyles ( ( { transitions, palette } ) => ( {
40- openDrawer : drawerCss ( true , transitions , palette ) ,
44+ const useStyles = makeStyles ( ( { transitions, palette, spacing } ) => ( {
45+ openDrawer : drawerCss ( true , transitions , palette , spacing ) ,
4146
42- closeDrawer : drawerCss ( false , transitions , palette ) ,
47+ closeDrawer : drawerCss ( false , transitions , palette , spacing ) ,
4348
44- colapse : {
49+ buttonContainer : { textAlign : 'end' } ,
50+ button : {
4551 color : 'white' ,
46- position : 'absolute' ,
47- bottom : 0 ,
48- right : 2
52+ marginBottom : spacing ( 1 ) ,
53+ marginRight : props => props . expand ? spacing ( 1 ) : 0 ,
54+ } ,
55+ text : { paddingLeft : spacing ( 1 ) } ,
56+ container : {
57+ display : 'flex' ,
58+ justifyContent : 'space-between' ,
59+ flexDirection : 'column' ,
60+ height : '100%'
4961 } ,
50- paper : { backgroundColor : palette . grey [ '900' ] } ,
5162
52- selected : { height : 48 , color : palette . primary . main } ,
53- unselected : { height : 48 , color : palette . common . white } ,
54- noColor : { color : 'inherit' }
63+ selected : { color : palette . primary . main , paddingLeft : spacing ( 1 ) } ,
64+ unselected : { color : palette . common . white , paddingLeft : spacing ( 1 ) } ,
65+ icon : { color : 'inherit' , minWidth : 'unset ' }
5566} ) )
5667
5768export default ( { widgets, newWidget, editMode } ) => {
5869 const [ expand , setExpand ] = useState ( { dark : ! editMode } )
5970
60- const classes = useStyles ( { width : expand ? drawerOpenWidth : drawerCloseWidth } ) ;
71+ const classes = useStyles ( { width : expand ? drawerOpenWidth : drawerCloseWidth , expand } ) ;
6172
6273 function createWidget ( widgetId ) {
6374 if ( ! widgets [ widgetId ] ) {
@@ -92,49 +103,48 @@ export default ({ widgets, newWidget, editMode }) => {
92103 }
93104
94105 return (
95- < div >
96- < Drawer
97- variant = "permanent"
98- className = { expand ? classes . openDrawer : classes . closeDrawer }
99- classes = { { paper : expand ? classes . openDrawer : classes . closeDrawer } }
100- >
101- < div >
102- < Toolbar />
106+ < Paper className = { expand ? classes . openDrawer : classes . closeDrawer } >
107+ < div className = { classes . container } >
108+ < div >
103109 < List dense >
104110 { getMenu ( ) . map ( ( { name, id } ) => (
105111 < ListItem
106112 button
107113 key = { name }
114+ dense
115+ disableGutters
108116 className = { widgets [ id ] ? classes . selected : classes . unselected }
109117 onClick = { ( ) => createWidget ( id ) }
110118 >
111- < ListItemIcon className = { classes . noColor } >
112- < AdjustIcon />
119+ < ListItemIcon className = { classes . icon } >
120+ < AdjustIcon fontSize = "large" />
113121 </ ListItemIcon >
114- < ListItemText >
122+ < ListItemText className = { classes . text } >
115123 < Typography noWrap > { name } </ Typography >
116124 </ ListItemText >
117125 </ ListItem >
118126 ) ) }
119127 </ List >
128+ </ div >
129+ < div > </ div >
120130
121-
131+ < div className = { classes . buttonContainer } >
122132 < IconButton
123- className = { classes . colapse }
133+ className = { classes . button }
124134 onClick = { ( ) => {
125135 setExpand ( ! expand )
126136 setTimeout ( ( ) => window . dispatchEvent ( new Event ( 'resize' ) ) , 400 )
127- // pepe()
137+ // pepe()
128138 } }
129139 >
130140 { expand ? < ChevronLeftIcon /> : < ChevronRightIcon /> }
131141 </ IconButton >
142+ </ div >
132143
133144
134- </ div >
145+ </ div >
135146
136- </ Drawer >
137- </ div >
147+ </ Paper >
138148 )
139149
140150}
0 commit comments