Skip to content

Commit 6d799b5

Browse files
Merge pull request #34 from karanBRAVO/bug/1
update sidebar ui/ux
2 parents 0ce54ca + 1fe5b62 commit 6d799b5

File tree

1 file changed

+49
-28
lines changed

1 file changed

+49
-28
lines changed

frontend/src/components/Layout.jsx

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
ListItemText,
1212
Toolbar,
1313
Typography,
14+
Tooltip,
1415
} from "@mui/material";
1516
import MenuIcon from "@mui/icons-material/Menu";
1617
import CloudIcon from "@mui/icons-material/Cloud";
@@ -92,36 +93,56 @@ const Layout = () => {
9293
}}
9394
>
9495
<Toolbar />
95-
<Box sx={{ overflow: "auto", flexGrow: 1 }}>
96+
<Box sx={{ overflow: "hidden auto", flexGrow: 1 }}>
9697
<List>
97-
{menuItems.map((item) => (
98-
<ListItem
99-
button
100-
key={item.text}
101-
component={Link}
102-
to={item.path}
103-
className={
104-
location.pathname === item.path
105-
? "active"
106-
: ""
107-
}
108-
sx={{
109-
"&.active": {
110-
bgcolor: "rgba(0, 0, 0, 0.08)",
111-
"& .MuiListItemIcon-root": {
112-
color: volcanoOrange,
98+
{menuItems.map((item) => {
99+
const listItem = (
100+
<ListItem
101+
key={item.text}
102+
component={Link}
103+
to={item.path}
104+
className={
105+
location.pathname === item.path
106+
? "active"
107+
: ""
108+
}
109+
sx={{
110+
"&.active": {
111+
bgcolor: "rgba(0, 0, 0, 0.08)",
112+
"& .MuiListItemIcon-root": {
113+
color: volcanoOrange,
114+
},
115+
"& .MuiListItemText-primary": {
116+
color: volcanoOrange,
117+
fontWeight: 500,
118+
},
113119
},
114-
"& .MuiListItemText-primary": {
115-
color: volcanoOrange,
116-
fontWeight: 500,
120+
"&:hover": {
121+
backgroundColor:
122+
"rgba(0, 0, 0, 0.1)",
117123
},
118-
},
119-
}}
120-
>
121-
<ListItemIcon>{item.icon}</ListItemIcon>
122-
{open && <ListItemText primary={item.text} />}
123-
</ListItem>
124-
))}
124+
}}
125+
>
126+
<ListItemIcon>{item.icon}</ListItemIcon>
127+
{open && (
128+
<ListItemText primary={item.text} />
129+
)}
130+
</ListItem>
131+
);
132+
return !open ? (
133+
<Tooltip
134+
key={item.text}
135+
title={item.text}
136+
placement="right"
137+
>
138+
{listItem}
139+
</Tooltip>
140+
) : (
141+
<React.Fragment key={item.text}>
142+
{listItem}
143+
</React.Fragment>
144+
);
145+
})}
125146
</List>
126147
</Box>
127148
{/* Logo and text part */}
@@ -141,7 +162,7 @@ const Layout = () => {
141162
src={volcanoLogo}
142163
alt="Volcano Logo"
143164
style={{
144-
maxWidth: open ? "115%" : "60px",
165+
maxWidth: open ? "150px" : "60px",
145166
height: "auto",
146167
transition: "max-width 0.2s",
147168
marginBottom: "1px",

0 commit comments

Comments
 (0)