1
- import React , { useState } from "react" ;
2
- import { Link , Outlet , useLocation } from "react-router-dom" ;
1
+ import React , { useState } from "react" ;
2
+ import { Link , Outlet , useLocation } from "react-router-dom" ;
3
3
import {
4
4
AppBar ,
5
5
Box ,
@@ -11,39 +11,39 @@ import {
11
11
ListItemText ,
12
12
Toolbar ,
13
13
Typography ,
14
+ Backdrop ,
14
15
} from "@mui/material" ;
15
16
import MenuIcon from "@mui/icons-material/Menu" ;
16
- import CloudIcon from ' @mui/icons-material/Cloud' ;
17
- import HomeIcon from ' @mui/icons-material/Home' ;
18
- import AssignmentIcon from ' @mui/icons-material/Assignment' ;
19
- import WorkspacesIcon from ' @mui/icons-material/Workspaces' ;
17
+ import CloudIcon from " @mui/icons-material/Cloud" ;
18
+ import HomeIcon from " @mui/icons-material/Home" ;
19
+ import AssignmentIcon from " @mui/icons-material/Assignment" ;
20
+ import WorkspacesIcon from " @mui/icons-material/Workspaces" ;
20
21
21
- // use relative path to load Logo
22
- import volcanoLogo from ' ../assets/volcano-icon-color.svg' ;
22
+ // Logo import
23
+ import volcanoLogo from " ../assets/volcano-icon-color.svg" ;
23
24
24
25
const Layout = ( ) => {
25
- // Hooks must be used inside component functions
26
26
const location = useLocation ( ) ;
27
- const [ open , setOpen ] = useState ( true ) ;
27
+ const [ open , setOpen ] = useState ( false ) ; // Set default to false for overlay effect
28
28
29
- // constants can be kept outside the component
30
- const volcanoOrange = "#E34C26" ; // orange red theme
31
- const headerGrey = "#424242" ; // dark gray top stripe
29
+ const volcanoOrange = "#E34C26" ;
30
+ const headerGrey = "#424242" ;
32
31
const drawerWidth = 240 ;
33
32
34
33
const handleDrawerToggle = ( ) => {
35
34
setOpen ( ! open ) ;
36
35
} ;
37
36
38
37
const menuItems = [
39
- { text : "Dashboard" , icon : < HomeIcon /> , path : "/dashboard" } ,
40
- { text : "Jobs" , icon : < AssignmentIcon /> , path : "/jobs" } ,
41
- { text : "Queues" , icon : < CloudIcon /> , path : "/queues" } ,
42
- { text : "Pods" , icon : < WorkspacesIcon /> , path : "/pods" } ,
38
+ { text : "Dashboard" , icon : < HomeIcon /> , path : "/dashboard" } ,
39
+ { text : "Jobs" , icon : < AssignmentIcon /> , path : "/jobs" } ,
40
+ { text : "Queues" , icon : < CloudIcon /> , path : "/queues" } ,
41
+ { text : "Pods" , icon : < WorkspacesIcon /> , path : "/pods" } ,
43
42
] ;
44
43
45
44
return (
46
- < Box sx = { { display : "flex" } } >
45
+ < Box sx = { { display : "flex" } } >
46
+ { /* Top Navigation Bar */ }
47
47
< AppBar
48
48
position = "fixed"
49
49
sx = { {
@@ -57,42 +57,42 @@ const Layout = () => {
57
57
aria-label = "toggle drawer"
58
58
onClick = { handleDrawerToggle }
59
59
edge = "start"
60
- sx = { { mr : 2 , color : "white" } }
60
+ sx = { { mr : 2 , color : "white" } }
61
61
>
62
- < MenuIcon />
62
+ < MenuIcon />
63
63
</ IconButton >
64
64
< Typography
65
65
variant = "h6"
66
66
noWrap
67
67
component = "div"
68
- sx = { {
69
- color : "#ffffff" ,
70
- fontWeight : 500 ,
71
- } }
68
+ sx = { { color : "#ffffff" , fontWeight : 500 } }
72
69
>
73
70
Volcano Dashboard
74
71
</ Typography >
75
72
</ Toolbar >
76
73
</ AppBar >
77
74
75
+ { /* Drawer (Overlay Style) */ }
78
76
< Drawer
79
- variant = "permanent"
77
+ variant = "temporary"
78
+ open = { open }
79
+ onClose = { handleDrawerToggle }
80
+ ModalProps = { {
81
+ keepMounted : true , // Improves performance on mobile
82
+ } }
80
83
sx = { {
81
- width : open ? drawerWidth : 60 ,
82
- flexShrink : 0 ,
83
- [ `& .MuiDrawer-paper` ] : {
84
- width : open ? drawerWidth : 60 ,
84
+ "& .MuiDrawer-paper" : {
85
+ width : drawerWidth ,
85
86
boxSizing : "border-box" ,
86
87
backgroundColor : "#f5f5f5" ,
87
- transition : "width 0.2s" ,
88
- overflowX : "hidden" ,
89
- display : "flex" ,
90
- flexDirection : "column" ,
88
+ position : "fixed" ,
89
+ height : "100vh" ,
90
+ transition : "width 0.2s ease-in-out" ,
91
91
} ,
92
92
} }
93
93
>
94
- < Toolbar />
95
- < Box sx = { { overflow : "auto" , flexGrow : 1 } } >
94
+ < Toolbar />
95
+ < Box sx = { { overflow : "auto" , flexGrow : 1 } } >
96
96
< List >
97
97
{ menuItems . map ( ( item ) => (
98
98
< ListItem
@@ -115,12 +115,13 @@ const Layout = () => {
115
115
} }
116
116
>
117
117
< ListItemIcon > { item . icon } </ ListItemIcon >
118
- { open && < ListItemText primary = { item . text } /> }
118
+ < ListItemText primary = { item . text } />
119
119
</ ListItem >
120
120
) ) }
121
121
</ List >
122
122
</ Box >
123
- { /* Logo and text part */ }
123
+
124
+ { /* Logo Section */ }
124
125
< Box
125
126
sx = { {
126
127
p : 1 ,
@@ -130,40 +131,43 @@ const Layout = () => {
130
131
alignItems : "center" ,
131
132
mt : "auto" ,
132
133
mb : 1 ,
133
- // borderTop: "1px solid rgba(0, 0, 0, 0.12)",
134
134
} }
135
135
>
136
- < img
137
- src = { volcanoLogo }
138
- alt = "Volcano Logo"
139
- style = { {
140
- maxWidth : open ? "115%" : "60px" ,
141
- height : "auto" ,
142
- transition : "max-width 0.2s" ,
143
- marginBottom : "1px" ,
144
- } }
145
- />
146
- { /* {open && (
147
- <Typography
148
- sx={{
149
- fontWeight: 700,
150
- color: "#000",
151
- fontSize: "1.4rem",
152
- letterSpacing: "0.1em",
153
- mt: -6,
154
- }}
155
- >
156
- VOLCANO
157
- </Typography>
158
- )} */ }
136
+ < img
137
+ src = { volcanoLogo }
138
+ alt = "Volcano Logo"
139
+ style = { {
140
+ maxWidth : "115%" ,
141
+ height : "auto" ,
142
+ marginBottom : "1px" ,
143
+ '@media (min-width: 600px)' : {
144
+ display : "block" ,
145
+ } ,
146
+ } }
147
+ />
159
148
</ Box >
160
149
</ Drawer >
150
+
151
+ { /* Backdrop (Dim screen when drawer is open) */ }
152
+ { open && (
153
+ < Backdrop
154
+ open = { open }
155
+ onClick = { handleDrawerToggle }
156
+ sx = { { zIndex : ( theme ) => theme . zIndex . drawer - 1 , backgroundColor : "rgba(0,0,0,0.4)" } }
157
+ />
158
+ ) }
159
+
160
+ { /* Main Content */ }
161
161
< Box
162
162
component = "main"
163
- sx = { { flexGrow : 1 , p : 3 , backgroundColor : "white" } }
163
+ sx = { {
164
+ flexGrow : 1 ,
165
+ p : 3 ,
166
+ backgroundColor : "white" ,
167
+ } }
164
168
>
165
- < Toolbar />
166
- < Outlet />
169
+ < Toolbar />
170
+ < Outlet />
167
171
</ Box >
168
172
</ Box >
169
173
) ;
0 commit comments