Files
Web-Frontend/client/src/components/layout/Sidebar.jsx
T

57 lines
2.1 KiB
React
Raw Normal View History

import {Mountain, House, Earth, MapPin, ShieldUser, PanelLeftClose, PanelLeftOpen} from 'lucide-react';
import {useSlotRecipe, Box, Button, IconButton, Text, Flex} from "@chakra-ui/react";
2026-08-26 13:04:17 -07:00
import {ColorModeButton} from "@/components/ui/color-mode.jsx";
import {NavLink} from "react-router-dom";
import {useState} from "react";
const SIDEBAR_DEFAULT_BUTTONS = [
2026-08-26 13:04:17 -07:00
{icon: House, name: "Home", url: "/home"},
{icon: Earth, name: "Global Map", url: "/global-map"},
{icon: MapPin, name: "Regional Map", url: "/regional-map"},
{icon: Mountain, name: "Volcano", url: "/volcano"},
{icon: ShieldUser, name: "Admin", url: "/admin"} // TODO remove in the future as default should not have admin
];
2026-06-04 15:30:01 -07:00
export default function Sidebar() {
const [isOpen, setIsOpen] = useState(true);
2026-08-26 13:04:17 -07:00
const recipe = useSlotRecipe({key: "sidebar"});
const styles = recipe({state: isOpen ? "open" : "closed"});
const visibleButtons = SIDEBAR_DEFAULT_BUTTONS; // TODO: call btns here according to users authorization
2026-06-04 15:30:01 -07:00
const toggleSidebar = () => setIsOpen((prev) => !prev);
return (
2026-08-26 13:04:17 -07:00
<Box css={styles.root}>
{/* Logo Navigates to Home Page */}
<Button as={NavLink} to="/home" variant="plain" css={styles.logo}>
<Flex>
<Text>🌋</Text>
<Text css={styles.logo_text}>VDAP</Text>
</Flex>
2026-08-26 13:04:17 -07:00
</Button>
{/* Navigation Buttons */}
{visibleButtons.map((button) => {
const Icon = button.icon;
return (
<Button as={NavLink} to={button.url} css={styles.buttons}> {/* Navigation buttons are [icon text] */}
2026-08-26 13:04:17 -07:00
<Icon/>
<Box as="span" css={styles.button_text}>
{button.name}
</Box>
</Button>
);
})}
{/* Collapse Sidebar and Theme Footer Buttons */}
<Flex css={styles.footer}>
<IconButton aria-label="Toggle Sidebar" variant="plain" onClick={toggleSidebar} css={styles.collapse_button}>
{isOpen ? <PanelLeftClose /> : <PanelLeftOpen />}
</IconButton>
<Flex css={styles.color_mode_button}>
<ColorModeButton />
</Flex>
</Flex>
</Box>
);
2025-07-17 09:45:36 -07:00
}