sidebar collapsible feature
The sidebar can now be collapsed to just its icons
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ function App() {
|
||||
return (
|
||||
<Grid
|
||||
templateRows="0.75fr 11.25fr"
|
||||
templateColumns="1fr 11fr"
|
||||
templateColumns="0.25fr 11.75fr"
|
||||
height="100vh"
|
||||
width="100vw"
|
||||
>
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Box, Button } from "@chakra-ui/react";
|
||||
import { FaVolcano } from "react-icons/fa6";
|
||||
import { createIcon } from "@chakra-ui/react";
|
||||
import { CloseButton } from "@chakra-ui/react";
|
||||
import { IconButton } from "@chakra-ui/react";
|
||||
import { RxHamburgerMenu } from "react-icons/rx";
|
||||
import { useState } from "react"
|
||||
|
||||
// ICONS
|
||||
@@ -58,7 +60,11 @@ export const Users = createIcon({
|
||||
});
|
||||
|
||||
export default function Sidebar () {
|
||||
const [isOpen, setIsOpen] = useState(true);
|
||||
|
||||
return (
|
||||
<>
|
||||
{isOpen && (
|
||||
<Box w="100%" h="100%"
|
||||
borderRight="1px"
|
||||
borderColor="black"
|
||||
@@ -67,14 +73,39 @@ export default function Sidebar () {
|
||||
flexDirection="column"
|
||||
justifyContent="start"
|
||||
alignItems="start"
|
||||
gap={4} padding={14}
|
||||
gap={4} paddingTop={4}
|
||||
paddingLeft={8} paddingRight={8}
|
||||
>
|
||||
<CloseButton color="#19332D" bg="#EDF1F1" size="xs" variant="subtle" position="relative" top="-12" left="-12"></CloseButton>
|
||||
<CloseButton color="#19332D" bg= "#EDF1F1" variant="subtle" left="-4" onClick={() => setIsOpen(!isOpen)}></CloseButton>
|
||||
<Button color="#19332D" _hover={{bg: "#EDF1F1"}} fontSize="xl" variant="ghost"><PushPin /> Dashboard</Button>
|
||||
<Button color="#19332D" _hover={{bg: "#EDF1F1"}} fontSize="xl" variant="ghost"><Globe fill="white" stroke="black" /> Global Map</Button>
|
||||
<Button color="#19332D" _hover={{bg: "#EDF1F1"}} fontSize="xl" variant="ghost"><MapMarker fill="white" stroke="black"/> Regional Map</Button>
|
||||
<Button color="#19332D" _hover={{bg: "#EDF1F1"}} fontSize="xl" variant="ghost"><FaVolcano /> Volcano</Button>
|
||||
<Button color="#19332D" _hover={{bg: "#EDF1F1"}} fontSize="xl" variant="ghost"><Users fill="white" stroke="black" /> Admin</Button>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{!isOpen && (
|
||||
<Box w="100%" h="100%"
|
||||
borderRight="1px"
|
||||
borderColor="black"
|
||||
borderStyle="solid"
|
||||
display="flex"
|
||||
flexDirection="column"
|
||||
justifyContent="start"
|
||||
alignItems="start"
|
||||
gap={4} padding={4}
|
||||
>
|
||||
<IconButton color="#19332D" _hover={{bg: "#EDF1F1"}} variant="ghost" onClick={() => setIsOpen(!isOpen)}>
|
||||
<RxHamburgerMenu />
|
||||
</IconButton>
|
||||
<IconButton color="#19332D" _hover={{bg: "#EDF1F1"}} variant="ghost" ><PushPin /> </IconButton>
|
||||
<IconButton color="#19332D" _hover={{bg: "#EDF1F1"}} variant="ghost" ><Globe fill="white" stroke="black" /> </IconButton>
|
||||
<IconButton color="#19332D" _hover={{bg: "#EDF1F1"}} variant="ghost" ><MapMarker fill="white" stroke="black" /> </IconButton>
|
||||
<IconButton color="#19332D" _hover={{bg: "#EDF1F1"}} variant="ghost" ><FaVolcano /> </IconButton>
|
||||
<IconButton color="#19332D" _hover={{bg: "#EDF1F1"}} variant="ghost" ><Users fill="white" stroke="black" /> </IconButton>
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user