1
+ import Drawer from "@material-ui/core/Drawer"
2
+ import IconButton from "@material-ui/core/IconButton"
1
3
import List from "@material-ui/core/List"
2
4
import ListItem from "@material-ui/core/ListItem"
3
5
import { fade , makeStyles } from "@material-ui/core/styles"
6
+ import MenuIcon from "@material-ui/icons/Menu"
7
+ import { useState } from "react"
4
8
import { NavLink , useLocation } from "react-router-dom"
5
9
import * as TypesGen from "../../api/typesGenerated"
6
10
import { navHeight } from "../../theme/constants"
@@ -19,41 +23,66 @@ export const Language = {
19
23
users : "Users" ,
20
24
}
21
25
22
- export const NavbarView : React . FC < NavbarViewProps > = ( { user , onSignOut } ) => {
26
+ const NavItems : React . FC < { className ?: string ; linkClassName ?: string } > = ( { className } ) => {
23
27
const styles = useStyles ( )
24
28
const location = useLocation ( )
29
+
30
+ return (
31
+ < List className = { combineClasses ( [ styles . navItems , className ] ) } >
32
+ < ListItem button className = { styles . item } >
33
+ < NavLink
34
+ className = { combineClasses ( [ styles . link , location . pathname . startsWith ( "/@" ) && "active" ] ) }
35
+ to = "/workspaces"
36
+ >
37
+ { Language . workspaces }
38
+ </ NavLink >
39
+ </ ListItem >
40
+ < ListItem button className = { styles . item } >
41
+ < NavLink className = { styles . link } to = "/templates" >
42
+ { Language . templates }
43
+ </ NavLink >
44
+ </ ListItem >
45
+ < ListItem button className = { styles . item } >
46
+ < NavLink className = { styles . link } to = "/users" >
47
+ { Language . users }
48
+ </ NavLink >
49
+ </ ListItem >
50
+ </ List >
51
+ )
52
+ }
53
+
54
+ export const NavbarView : React . FC < NavbarViewProps > = ( { user, onSignOut } ) => {
55
+ const styles = useStyles ( )
56
+ const [ isDrawerOpen , setIsDrawerOpen ] = useState ( false )
57
+
25
58
return (
26
59
< nav className = { styles . root } >
27
- < List className = { styles . fixed } >
28
- < ListItem className = { styles . item } >
29
- < NavLink className = { styles . logo } to = "/workspaces" >
60
+ < IconButton
61
+ aria-label = "Open menu"
62
+ className = { styles . mobileMenuButton }
63
+ onClick = { ( ) => {
64
+ setIsDrawerOpen ( true )
65
+ } }
66
+ >
67
+ < MenuIcon />
68
+ </ IconButton >
69
+
70
+ < Drawer anchor = "left" open = { isDrawerOpen } onClose = { ( ) => setIsDrawerOpen ( false ) } >
71
+ < div className = { styles . drawer } >
72
+ < div className = { styles . drawerHeader } >
30
73
< Logo fill = "white" opacity = { 1 } width = { 125 } />
31
- </ NavLink >
32
- </ ListItem >
33
- < ListItem button className = { styles . item } >
34
- < NavLink
35
- className = { combineClasses ( [
36
- styles . link ,
37
- location . pathname . startsWith ( "/@" ) && "active" ,
38
- ] ) }
39
- to = "/workspaces"
40
- >
41
- { Language . workspaces }
42
- </ NavLink >
43
- </ ListItem >
44
- < ListItem button className = { styles . item } >
45
- < NavLink className = { styles . link } to = "/templates" >
46
- { Language . templates }
47
- </ NavLink >
48
- </ ListItem >
49
- < ListItem button className = { styles . item } >
50
- < NavLink className = { styles . link } to = "/users" >
51
- { Language . users }
52
- </ NavLink >
53
- </ ListItem >
54
- </ List >
55
- < div className = { styles . fullWidth } />
56
- < div className = { styles . fixed } >
74
+ </ div >
75
+ < NavItems />
76
+ </ div >
77
+ </ Drawer >
78
+
79
+ < NavLink className = { styles . logo } to = "/workspaces" >
80
+ < Logo fill = "white" opacity = { 1 } width = { 125 } />
81
+ </ NavLink >
82
+
83
+ < NavItems className = { styles . desktopNavItems } />
84
+
85
+ < div className = { styles . profileButton } >
57
86
{ user && < UserDropdown user = { user } onSignOut = { onSignOut } /> }
58
87
</ div >
59
88
</ nav >
@@ -64,9 +93,7 @@ const useStyles = makeStyles((theme) => ({
64
93
root : {
65
94
position : "relative" ,
66
95
display : "flex" ,
67
- flex : 0 ,
68
- flexDirection : "row" ,
69
- justifyContent : "center" ,
96
+ justifyContent : "space-between" ,
70
97
alignItems : "center" ,
71
98
height : navHeight ,
72
99
background : theme . palette . background . paper ,
@@ -76,14 +103,37 @@ const useStyles = makeStyles((theme) => ({
76
103
borderTop : `1px solid ${ theme . palette . divider } ` ,
77
104
} ,
78
105
borderBottom : `1px solid ${ theme . palette . divider } ` ,
106
+
107
+ [ theme . breakpoints . up ( "md" ) ] : {
108
+ justifyContent : "flex-start" ,
109
+ } ,
79
110
} ,
80
- fixed : {
81
- flex : 0 ,
82
- display : "flex" ,
111
+ drawer : {
112
+ width : 250 ,
113
+ } ,
114
+ drawerHeader : {
115
+ padding : theme . spacing ( 2 ) ,
116
+ paddingTop : theme . spacing ( 4 ) ,
117
+ paddingBottom : theme . spacing ( 4 ) ,
118
+ } ,
119
+ navItems : {
83
120
padding : 0 ,
84
121
} ,
85
- fullWidth : {
86
- flex : 1 ,
122
+ desktopNavItems : {
123
+ display : "none" ,
124
+ [ theme . breakpoints . up ( "md" ) ] : {
125
+ display : "flex" ,
126
+ } ,
127
+ } ,
128
+ profileButton : {
129
+ [ theme . breakpoints . up ( "md" ) ] : {
130
+ marginLeft : "auto" ,
131
+ } ,
132
+ } ,
133
+ mobileMenuButton : {
134
+ [ theme . breakpoints . up ( "md" ) ] : {
135
+ display : "none" ,
136
+ } ,
87
137
} ,
88
138
logo : {
89
139
alignItems : "center" ,
@@ -107,8 +157,7 @@ const useStyles = makeStyles((theme) => ({
107
157
color : "hsl(220, 11%, 71%)" ,
108
158
display : "flex" ,
109
159
fontSize : 16 ,
110
- height : navHeight ,
111
- padding : `0 ${ theme . spacing ( 3 ) } px` ,
160
+ padding : `${ theme . spacing ( 1.5 ) } px ${ theme . spacing ( 2 ) } px` ,
112
161
textDecoration : "none" ,
113
162
transition : "background-color 0.3s ease" ,
114
163
@@ -124,13 +173,25 @@ const useStyles = makeStyles((theme) => ({
124
173
125
174
"&::before" : {
126
175
content : `" "` ,
127
- bottom : 0 ,
128
- left : theme . spacing ( 3 ) ,
176
+ left : 0 ,
177
+ width : 2 ,
178
+ height : "100%" ,
129
179
background : theme . palette . secondary . dark ,
130
- right : theme . spacing ( 3 ) ,
131
- height : 2 ,
132
180
position : "absolute" ,
181
+
182
+ [ theme . breakpoints . up ( "md" ) ] : {
183
+ bottom : 0 ,
184
+ left : theme . spacing ( 3 ) ,
185
+ width : `calc(100% - 2 * ${ theme . spacing ( 3 ) } px)` ,
186
+ right : theme . spacing ( 3 ) ,
187
+ height : 2 ,
188
+ } ,
133
189
} ,
134
190
} ,
191
+
192
+ [ theme . breakpoints . up ( "md" ) ] : {
193
+ height : navHeight ,
194
+ padding : `0 ${ theme . spacing ( 3 ) } px` ,
195
+ } ,
135
196
} ,
136
197
} ) )
0 commit comments