create sidebarClassName variable and update in jsx
This commit is contained in:
1 parent
ac57e1ec27
commit
865140a205
1 file changed
+4
-2
@@ -129,13 +129,14 @@ function Sidebar() {
|
|||||||
);
|
);
|
||||||
const sidebarRef = useRef(null);
|
const sidebarRef = useRef(null);
|
||||||
const [sidebarReady, setSidebarReady] = useState(false);
|
const [sidebarReady, setSidebarReady] = useState(false);
|
||||||
|
const TRANSITION_DURATION = 200;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!collapsed) {
|
if (!collapsed) {
|
||||||
setSidebarReady(false);
|
setSidebarReady(false);
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
setSidebarReady(true);
|
setSidebarReady(true);
|
||||||
}, 200);
|
}, TRANSITION_DURATION);
|
||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
} else {
|
} else {
|
||||||
setSidebarReady(false);
|
setSidebarReady(false);
|
||||||
@@ -205,13 +206,14 @@ function Sidebar() {
|
|||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
const iconColor = theme.palette.primary.contrastTextTertiary;
|
const iconColor = theme.palette.primary.contrastTextTertiary;
|
||||||
|
const sidebarClassName = `${collapsed ? "collapsed" : "expanded"} ${sidebarReady ? "sidebar-ready" : ""}`;
|
||||||
|
|
||||||
/* TODO refactor this, there are a some ternaries and comments in the return */
|
/* TODO refactor this, there are a some ternaries and comments in the return */
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
component="aside"
|
component="aside"
|
||||||
ref={sidebarRef}
|
ref={sidebarRef}
|
||||||
className={`${collapsed ? "collapsed" : "expanded"} ${sidebarReady ? "sidebar-ready" : ""}`}
|
className={sidebarClassName}
|
||||||
/* TODO general padding should be here */
|
/* TODO general padding should be here */
|
||||||
py={theme.spacing(6)}
|
py={theme.spacing(6)}
|
||||||
gap={theme.spacing(6)}
|
gap={theme.spacing(6)}
|
||||||
|
|||||||
Reference in new issue
Block a user