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

75 lines
2.3 KiB
React
Raw Normal View History

2026-08-26 13:04:17 -07:00
import {useSlotRecipe, Box, Button, IconButton} from "@chakra-ui/react";
import {ColorModeButton} from "@/components/ui/color-mode.jsx";
import {useState} from "react";
import {NavLink} from "react-router-dom";
2026-06-10 14:00:37 -07:00
import Tooltip from "../ui/Tooltip.jsx";
2026-08-26 13:04:17 -07:00
import {Mountain, House, Earth, MapPin, ShieldUser, Menu, PanelLeftClose, PanelLeftOpen} from 'lucide-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() {
2026-08-26 13:04:17 -07:00
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"});
2025-07-17 09:45:36 -07:00
// TODO we will need to call buttons here by authorized user, for now we update the visible buttons as simply the default buttons
const visibleButtons = SIDEBAR_DEFAULT_BUTTONS;
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}>
{/* Home Link Logo */}
<Button
as={NavLink}
to="/home"
css={styles.logo}
variant="plain"
>
2026-08-26 13:04:17 -07:00
{isOpen ? "🌋 VDAP" : "🌋"}
</Button>
{/* Navigation Buttons */}
{visibleButtons.map((button) => {
const Icon = button.icon;
return (
<Button
as={NavLink}
2026-08-26 13:04:17 -07:00
to={button.url}
css={styles.buttons}
>
2026-08-26 13:04:17 -07:00
{/* Navigation buttons are [icon text] */}
<Icon/>
<Box as="span" css={styles.button_text}>
{button.name}
</Box>
</Button>
);
})}
<Box css={styles.footer}>
{/* Menu Trigger */}
<IconButton
aria-label="Toggle Sidebar"
variant="plain"
size="md"
onClick={toggleSidebar}
css={styles.collapse_button}
>
{isOpen ? <PanelLeftClose /> : <PanelLeftOpen />}
</IconButton>
{/* Theme Toggler */}
<ColorModeButton _hover={{ bg: "transparent" }} />
</Box>
</Box>
);
2025-07-17 09:45:36 -07:00
}