Skip to content

Commit 780acca

Browse files
committed
fixed drawer shifting issue
Signed-off-by: Shruti78 <[email protected]> fixed logo fix issue Signed-off-by: Shruti78 <[email protected]> Save changes to Queues.jsx
1 parent 04320cc commit 780acca

File tree

2 files changed

+70
-66
lines changed

2 files changed

+70
-66
lines changed

frontend/src/components/Layout.jsx

+68-64
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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";
33
import {
44
AppBar,
55
Box,
@@ -11,39 +11,39 @@ import {
1111
ListItemText,
1212
Toolbar,
1313
Typography,
14+
Backdrop,
1415
} from "@mui/material";
1516
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";
2021

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";
2324

2425
const Layout = () => {
25-
// Hooks must be used inside component functions
2626
const location = useLocation();
27-
const [open, setOpen] = useState(true);
27+
const [open, setOpen] = useState(false); // Set default to false for overlay effect
2828

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";
3231
const drawerWidth = 240;
3332

3433
const handleDrawerToggle = () => {
3534
setOpen(!open);
3635
};
3736

3837
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" },
4342
];
4443

4544
return (
46-
<Box sx={{display: "flex"}}>
45+
<Box sx={{ display: "flex" }}>
46+
{/* Top Navigation Bar */}
4747
<AppBar
4848
position="fixed"
4949
sx={{
@@ -57,42 +57,42 @@ const Layout = () => {
5757
aria-label="toggle drawer"
5858
onClick={handleDrawerToggle}
5959
edge="start"
60-
sx={{mr: 2, color: "white"}}
60+
sx={{ mr: 2, color: "white" }}
6161
>
62-
<MenuIcon/>
62+
<MenuIcon />
6363
</IconButton>
6464
<Typography
6565
variant="h6"
6666
noWrap
6767
component="div"
68-
sx={{
69-
color: "#ffffff",
70-
fontWeight: 500,
71-
}}
68+
sx={{ color: "#ffffff", fontWeight: 500 }}
7269
>
7370
Volcano Dashboard
7471
</Typography>
7572
</Toolbar>
7673
</AppBar>
7774

75+
{/* Drawer (Overlay Style) */}
7876
<Drawer
79-
variant="permanent"
77+
variant="temporary"
78+
open={open}
79+
onClose={handleDrawerToggle}
80+
ModalProps={{
81+
keepMounted: true, // Improves performance on mobile
82+
}}
8083
sx={{
81-
width: open ? drawerWidth : 60,
82-
flexShrink: 0,
83-
[`& .MuiDrawer-paper`]: {
84-
width: open ? drawerWidth : 60,
84+
"& .MuiDrawer-paper": {
85+
width: drawerWidth,
8586
boxSizing: "border-box",
8687
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",
9191
},
9292
}}
9393
>
94-
<Toolbar/>
95-
<Box sx={{overflow: "auto", flexGrow: 1}}>
94+
<Toolbar />
95+
<Box sx={{ overflow: "auto", flexGrow: 1 }}>
9696
<List>
9797
{menuItems.map((item) => (
9898
<ListItem
@@ -115,12 +115,13 @@ const Layout = () => {
115115
}}
116116
>
117117
<ListItemIcon>{item.icon}</ListItemIcon>
118-
{open && <ListItemText primary={item.text}/>}
118+
<ListItemText primary={item.text} />
119119
</ListItem>
120120
))}
121121
</List>
122122
</Box>
123-
{/* Logo and text part */}
123+
124+
{/* Logo Section */}
124125
<Box
125126
sx={{
126127
p: 1,
@@ -130,40 +131,43 @@ const Layout = () => {
130131
alignItems: "center",
131132
mt: "auto",
132133
mb: 1,
133-
// borderTop: "1px solid rgba(0, 0, 0, 0.12)",
134134
}}
135135
>
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+
/>
159148
</Box>
160149
</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 */}
161161
<Box
162162
component="main"
163-
sx={{flexGrow: 1, p: 3, backgroundColor: "white"}}
163+
sx={{
164+
flexGrow: 1,
165+
p: 3,
166+
backgroundColor: "white",
167+
}}
164168
>
165-
<Toolbar/>
166-
<Outlet/>
169+
<Toolbar />
170+
<Outlet />
167171
</Box>
168172
</Box>
169173
);

frontend/src/components/Queues.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ const Queues = () => {
371371
</TableRow>
372372
</TableHead>
373373
<TableBody>
374-
{sortedQueues
374+
{sortedQueues
375375
.map((queue) => (
376376
<TableRow
377377
hover
@@ -407,7 +407,7 @@ const Queues = () => {
407407
</TableCell>
408408
</TableRow>
409409
))}
410-
< /TableBody>
410+
</TableBody>
411411
</Table>
412412
</TableContainer>
413413
<Box

0 commit comments

Comments
 (0)