Merge branch 'refactor/sidebar-transition' into 'main'
Refactor/sidebar transition See merge request vkuchenik/website-framework!9
This commit is contained in:
@@ -68,16 +68,18 @@ export default function Sidebar() {
|
|||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
setHasFinishedClosing(false);
|
setHasFinishedClosing(false);
|
||||||
setTimeout(() => setIsOpen(false), 10); // Kick off transition
|
setTimeout(() => setIsOpen(false), 10); // Kick off transition
|
||||||
setTimeout(() => setHasFinishedClosing(true), 400) // Match sidebar transition duration
|
setTimeout(() => setHasFinishedClosing(true), 400); // Match sidebar transition duration
|
||||||
} else {
|
} else {
|
||||||
setIsOpen(true);
|
setIsOpen(true);
|
||||||
setHasFinishedClosing(true);
|
setHasFinishedClosing(true);
|
||||||
|
// setTimeout(() => setIsOpen(true), 5);
|
||||||
|
// setTimeout(() => setHasFinishedClosing(false), 200);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
w={isOpen ? "250px" : "70px"}
|
w={isOpen ? "220px" : "86px"}
|
||||||
h="100vh"
|
h="100vh"
|
||||||
transition="width 0.4s ease"
|
transition="width 0.4s ease"
|
||||||
borderRight="1px solid black"
|
borderRight="1px solid black"
|
||||||
@@ -105,7 +107,8 @@ export default function Sidebar() {
|
|||||||
color="#19332D"
|
color="#19332D"
|
||||||
fontSize="lg"
|
fontSize="lg"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "center"}
|
// justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "flex-start"}
|
||||||
|
justifyContent="flex-start"
|
||||||
w="100%"
|
w="100%"
|
||||||
onClick={() => setActiveButton("Dashboard")}
|
onClick={() => setActiveButton("Dashboard")}
|
||||||
// onClick={toggleSidebar}
|
// onClick={toggleSidebar}
|
||||||
@@ -147,6 +150,52 @@ export default function Sidebar() {
|
|||||||
|
|
||||||
{/* Global Map */}
|
{/* Global Map */}
|
||||||
<Button
|
<Button
|
||||||
|
color="#19332D"
|
||||||
|
fontSize="lg"
|
||||||
|
variant="ghost"
|
||||||
|
// justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "center"}
|
||||||
|
justifyContent="flex-start"
|
||||||
|
w="100%"
|
||||||
|
onClick={() => setActiveButton("Global")}
|
||||||
|
// onClick={toggleSidebar}
|
||||||
|
bg={activeButton === "Global" ? "#A4B6B6" : "transparent"}
|
||||||
|
_hover={{
|
||||||
|
bg: activeButton === "Global" ? "#A4B6B6" : "#EDF1F1",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isOpen ? (
|
||||||
|
<>
|
||||||
|
{/* <PushPin boxSize={5} style={{ marginRight: "8px" }} /> */}
|
||||||
|
|
||||||
|
<Globe fill="white" stroke="black" />
|
||||||
|
|
||||||
|
{/* Make text appear gradually instead of popping in */}
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
marginLeft: "8px",
|
||||||
|
opacity: isOpen ? 1 : 0,
|
||||||
|
maxWidth: isOpen ? "250px" : "0px", // prevent layout from expanding before fade-in
|
||||||
|
overflow: "hidden",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
display: "inline-block",
|
||||||
|
transitionProperty: "opacity, max-width",
|
||||||
|
transitionDuration: "0.3s",
|
||||||
|
transitionTimingFunction: "ease",
|
||||||
|
transitionDelay: isOpen ? "0.1s" : "0s",
|
||||||
|
visibility: isOpen || !hasFinishedClosing ? "visible" : "hidden",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Dashboard
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
// <PushPin boxSize={5} />
|
||||||
|
<Globe fill="white" stroke="black" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* EXPERIMENTAL STYLING */}
|
||||||
|
{/* <Button
|
||||||
color="#19332D"
|
color="#19332D"
|
||||||
fontSize="lg"
|
fontSize="lg"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@@ -165,11 +214,10 @@ export default function Sidebar() {
|
|||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
display="flex"
|
display="flex"
|
||||||
alignItems="flex-start"
|
alignItems="center"
|
||||||
pl={ isOpen ? "0px" : "24px" }
|
pl={ isOpen ? "0px" : "24px" }
|
||||||
// w="100%"
|
// w="100%"
|
||||||
>
|
>
|
||||||
{/* Fixed-width icon container (works both open & closed) */}
|
|
||||||
<Box
|
<Box
|
||||||
w="70px" // Match closed sidebar width
|
w="70px" // Match closed sidebar width
|
||||||
display="flex"
|
display="flex"
|
||||||
@@ -177,7 +225,6 @@ export default function Sidebar() {
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
flexShrink={0}
|
flexShrink={0}
|
||||||
>
|
>
|
||||||
{/* <Globe boxSize={5} style={{ marginRight: "8px" }} /> */}
|
|
||||||
<Globe fill="white" stroke="black" />
|
<Globe fill="white" stroke="black" />
|
||||||
</Box>
|
</Box>
|
||||||
<span
|
<span
|
||||||
@@ -211,14 +258,15 @@ export default function Sidebar() {
|
|||||||
<Globe fill="white" stroke="black" />
|
<Globe fill="white" stroke="black" />
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button> */}
|
||||||
|
|
||||||
{/* Regional Map */}
|
{/* Regional Map */}
|
||||||
<Button
|
<Button
|
||||||
color="#19332D"
|
color="#19332D"
|
||||||
fontSize="lg"
|
fontSize="lg"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "center"}
|
// justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "center"}
|
||||||
|
justifyContent="flex-start"
|
||||||
w="100%"
|
w="100%"
|
||||||
onClick={() => setActiveButton("Regional")}
|
onClick={() => setActiveButton("Regional")}
|
||||||
bg={activeButton === "Regional" ? "#A4B6B6" : "transparent"}
|
bg={activeButton === "Regional" ? "#A4B6B6" : "transparent"}
|
||||||
@@ -260,7 +308,8 @@ export default function Sidebar() {
|
|||||||
color="#19332D"
|
color="#19332D"
|
||||||
fontSize="lg"
|
fontSize="lg"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "center"}
|
// justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "center"}
|
||||||
|
justifyContent="flex-start"
|
||||||
w="100%"
|
w="100%"
|
||||||
onClick={() => setActiveButton("Volcano")}
|
onClick={() => setActiveButton("Volcano")}
|
||||||
bg={activeButton === "Volcano" ? "#A4B6B6" : "transparent"}
|
bg={activeButton === "Volcano" ? "#A4B6B6" : "transparent"}
|
||||||
@@ -270,7 +319,8 @@ export default function Sidebar() {
|
|||||||
>
|
>
|
||||||
{isOpen ? (
|
{isOpen ? (
|
||||||
<>
|
<>
|
||||||
<FaVolcano size={20} style={{ marginRight: "8px" }} />
|
{/* <FaVolcano size={20} style={{ marginRight: "1px" }} /> */}
|
||||||
|
<FaVolcano />
|
||||||
{/* Make text appear gradually instead of popping in */}
|
{/* Make text appear gradually instead of popping in */}
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
@@ -301,7 +351,8 @@ export default function Sidebar() {
|
|||||||
color="#19332D"
|
color="#19332D"
|
||||||
fontSize="lg"
|
fontSize="lg"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "center"}
|
// justifyContent={isOpen || !hasFinishedClosing ? "flex-start" : "center"}
|
||||||
|
justifyContent="flex-start"
|
||||||
w="100%"
|
w="100%"
|
||||||
onClick={() => setActiveButton("Admin")}
|
onClick={() => setActiveButton("Admin")}
|
||||||
bg={activeButton === "Admin" ? "#A4B6B6" : "transparent"}
|
bg={activeButton === "Admin" ? "#A4B6B6" : "transparent"}
|
||||||
|
|||||||
Reference in New Issue
Block a user