Skip to content

Commit bc80ea9

Browse files
committed
refactor: align right sidebar animation mechanism with left sidebar
Replace Box component with MuiDrawer for the right sidebar to match the left sidebar's implementation. Both sidebars now use identical patterns: persistent/temporary variants, fixed width, and margin-based content shifting for open/close transitions.
1 parent 21dea16 commit bc80ea9

File tree

2 files changed

+68
-25
lines changed

2 files changed

+68
-25
lines changed

src/features/sidebar/view/internal/secondary/Container.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,20 @@ interface WrapperStackProps {
4747

4848
const WrapperStack = styled(Stack, {
4949
shouldForwardProp: (prop) => prop !== "isSidebarOpen" && prop !== "sidebarWidth" && prop !== "diffWidth" && prop !== "isDiffOpen"
50-
})<WrapperStackProps>(({ theme, sidebarWidth, isSidebarOpen, diffWidth: _diffWidth, isDiffOpen }) => {
51-
52-
50+
})<WrapperStackProps>(({ theme, sidebarWidth, isSidebarOpen, diffWidth, isDiffOpen }) => {
5351
return {
5452
transition: theme.transitions.create(["margin", "width"], {
5553
easing: theme.transitions.easing.sharp,
5654
duration: theme.transitions.duration.leavingScreen
5755
}),
5856
marginLeft: isSidebarOpen ? 0 : `-${sidebarWidth}px`,
59-
...(isSidebarOpen && {
57+
marginRight: isDiffOpen ? 0 : `-${diffWidth}px`,
58+
...((isSidebarOpen || isDiffOpen) && {
6059
transition: theme.transitions.create(["margin", "width"], {
6160
easing: theme.transitions.easing.easeOut,
6261
duration: theme.transitions.duration.enteringScreen,
6362
}),
6463
}),
65-
...(isDiffOpen && {
66-
transition: theme.transitions.create(["margin", "width"], {
67-
easing: theme.transitions.easing.easeOut,
68-
duration: theme.transitions.duration.enteringScreen,
69-
}),
70-
})
7164
};
7265
})
7366

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,87 @@
11
'use client'
22

3-
import { Box } from "@mui/material"
4-
import { useTheme } from "@mui/material/styles"
3+
import { SxProps } from "@mui/system"
4+
import { Drawer as MuiDrawer } from "@mui/material"
5+
import { useTheme } from "@mui/material/styles"
56

67
const RightContainer = ({
78
width,
89
isOpen,
9-
onClose: _onClose,
10+
onClose,
1011
children
1112
}: {
1213
width: number
1314
isOpen: boolean
1415
onClose?: () => void
1516
children?: React.ReactNode
17+
}) => {
18+
return (
19+
<>
20+
<InnerRightContainer
21+
variant="temporary"
22+
width={width}
23+
isOpen={isOpen}
24+
onClose={onClose}
25+
keepMounted={true}
26+
sx={{ display: { xs: "block", sm: "none" } }}
27+
>
28+
{children}
29+
</InnerRightContainer>
30+
<InnerRightContainer
31+
variant="persistent"
32+
width={width}
33+
isOpen={isOpen}
34+
keepMounted={false}
35+
sx={{ display: { xs: "none", sm: "block" } }}
36+
>
37+
{children}
38+
</InnerRightContainer>
39+
</>
40+
)
41+
}
42+
43+
export default RightContainer
44+
45+
const InnerRightContainer = ({
46+
variant,
47+
width,
48+
isOpen,
49+
onClose,
50+
keepMounted,
51+
sx,
52+
children
53+
}: {
54+
variant: "persistent" | "temporary"
55+
width: number
56+
isOpen: boolean
57+
onClose?: () => void
58+
keepMounted?: boolean
59+
sx: SxProps
60+
children?: React.ReactNode
1661
}) => {
1762
const theme = useTheme()
18-
19-
if (!isOpen) {
20-
return null
21-
}
22-
2363
return (
24-
<Box
64+
<MuiDrawer
65+
variant={variant}
66+
anchor="right"
67+
open={isOpen}
68+
onClose={onClose}
69+
ModalProps={{
70+
keepMounted: keepMounted || false
71+
}}
2572
sx={{
73+
...sx,
2674
width: width,
27-
height: "100%",
28-
backgroundColor: theme.palette.background.default,
2975
flexShrink: 0,
76+
"& .MuiDrawer-paper": {
77+
width: width,
78+
boxSizing: "border-box",
79+
borderLeft: 0,
80+
background: theme.palette.background.default
81+
}
3082
}}
3183
>
3284
{children}
33-
</Box>
85+
</MuiDrawer>
3486
)
35-
}
36-
37-
export default RightContainer
87+
}

0 commit comments

Comments
 (0)