|
1 | 1 | import { useEffect } from "react"; |
| 2 | +import Backdrop from "@mui/material/Backdrop"; |
2 | 3 | import Stack from "@mui/material/Stack"; |
3 | 4 | import List from "@mui/material/List"; |
4 | 5 | import Divider from "@mui/material/Divider"; |
@@ -51,71 +52,80 @@ export const Sidebar = () => { |
51 | 52 | }; |
52 | 53 |
|
53 | 54 | return ( |
54 | | - <Stack |
55 | | - component="aside" |
56 | | - position={isSmall ? "fixed" : "sticky"} |
57 | | - top={0} |
58 | | - left={0} |
59 | | - minHeight={"100vh"} |
60 | | - maxHeight={"100vh"} |
61 | | - paddingTop={theme.spacing(6)} |
62 | | - paddingBottom={theme.spacing(6)} |
63 | | - gap={theme.spacing(6)} |
64 | | - borderRight={`1px solid ${theme.palette.divider}`} |
65 | | - width={width} |
66 | | - sx={{ |
67 | | - transition: transition, |
68 | | - zIndex: isSmall ? (t) => t.zIndex.drawer : "auto", |
69 | | - }} |
70 | | - > |
71 | | - <List |
72 | | - component="nav" |
73 | | - disablePadding |
| 55 | + <> |
| 56 | + <Backdrop |
| 57 | + open={!collapsed && isSmall} |
| 58 | + onClick={() => dispatch(setCollapsed({ collapsed: true }))} |
| 59 | + sx={{ zIndex: 999 }} |
| 60 | + /> |
| 61 | + <Stack |
| 62 | + component="aside" |
| 63 | + position={isSmall ? "fixed" : "sticky"} |
| 64 | + top={0} |
| 65 | + left={0} |
| 66 | + minHeight={"100vh"} |
| 67 | + maxHeight={"100vh"} |
| 68 | + paddingTop={theme.spacing(6)} |
| 69 | + paddingBottom={theme.spacing(6)} |
| 70 | + gap={theme.spacing(6)} |
| 71 | + borderRight={`1px solid ${theme.palette.divider}`} |
| 72 | + width={width} |
74 | 73 | sx={{ |
75 | | - px: theme.spacing(6), |
76 | | - flex: 1, |
| 74 | + touchAction: "none", |
| 75 | + transition: transition, |
| 76 | + zIndex: 1000, |
| 77 | + backdropFilter: "blur(8px)", |
77 | 78 | }} |
78 | 79 | > |
79 | | - <Logo |
80 | | - pt={theme.spacing(8)} |
81 | | - pb={theme.spacing(10)} |
82 | | - /> |
83 | | - {menu.map((item) => { |
84 | | - const selected = location.pathname.startsWith(`/${item.path}`); |
85 | | - return ( |
86 | | - <NavItem |
87 | | - key={item.path} |
88 | | - item={item} |
89 | | - selected={selected} |
90 | | - onClick={() => handleNavClick(item.path)} |
91 | | - /> |
92 | | - ); |
93 | | - })} |
94 | | - </List> |
95 | | - <StarPrompt /> |
96 | | - <List |
97 | | - component="nav" |
98 | | - disablePadding |
99 | | - sx={{ px: theme.spacing(6) }} |
100 | | - > |
101 | | - {bottomMenu.map((item) => { |
102 | | - const selected = location.pathname.startsWith(`/${item.path}`); |
103 | | - return ( |
104 | | - <NavItem |
105 | | - key={item.path} |
106 | | - item={item} |
107 | | - selected={selected} |
108 | | - onClick={() => handleNavClick(item.path)} |
109 | | - /> |
110 | | - ); |
111 | | - })} |
112 | | - </List> |
113 | | - <Divider sx={{ borderColor: theme.palette.divider }} /> |
| 80 | + <List |
| 81 | + component="nav" |
| 82 | + disablePadding |
| 83 | + sx={{ |
| 84 | + px: theme.spacing(6), |
| 85 | + flex: 1, |
| 86 | + }} |
| 87 | + > |
| 88 | + <Logo |
| 89 | + pt={theme.spacing(8)} |
| 90 | + pb={theme.spacing(10)} |
| 91 | + /> |
| 92 | + {menu.map((item) => { |
| 93 | + const selected = location.pathname.startsWith(`/${item.path}`); |
| 94 | + return ( |
| 95 | + <NavItem |
| 96 | + key={item.path} |
| 97 | + item={item} |
| 98 | + selected={selected} |
| 99 | + onClick={() => handleNavClick(item.path)} |
| 100 | + /> |
| 101 | + ); |
| 102 | + })} |
| 103 | + </List> |
| 104 | + <StarPrompt /> |
| 105 | + <List |
| 106 | + component="nav" |
| 107 | + disablePadding |
| 108 | + sx={{ px: theme.spacing(6) }} |
| 109 | + > |
| 110 | + {bottomMenu.map((item) => { |
| 111 | + const selected = location.pathname.startsWith(`/${item.path}`); |
| 112 | + return ( |
| 113 | + <NavItem |
| 114 | + key={item.path} |
| 115 | + item={item} |
| 116 | + selected={selected} |
| 117 | + onClick={() => handleNavClick(item.path)} |
| 118 | + /> |
| 119 | + ); |
| 120 | + })} |
| 121 | + </List> |
| 122 | + <Divider sx={{ borderColor: theme.palette.divider }} /> |
114 | 123 |
|
115 | | - <AuthFooter |
116 | | - collapsed={collapsed} |
117 | | - accountMenuItems={accountMenu} |
118 | | - /> |
119 | | - </Stack> |
| 124 | + <AuthFooter |
| 125 | + collapsed={collapsed} |
| 126 | + accountMenuItems={accountMenu} |
| 127 | + /> |
| 128 | + </Stack> |
| 129 | + </> |
120 | 130 | ); |
121 | 131 | }; |
0 commit comments