| 1 | import React from "react";
|
|---|
| 2 | import { NavLink, useLocation } from "react-router-dom";
|
|---|
| 3 |
|
|---|
| 4 | import {
|
|---|
| 5 | Button,
|
|---|
| 6 | Sidebar,
|
|---|
| 7 | SidebarContent,
|
|---|
| 8 | SidebarHeader,
|
|---|
| 9 | SidebarMenu,
|
|---|
| 10 | SidebarMenuButton,
|
|---|
| 11 | SidebarMenuItem,
|
|---|
| 12 | } from "@relume_io/relume-ui";
|
|---|
| 13 |
|
|---|
| 14 | import {
|
|---|
| 15 | MdTune,
|
|---|
| 16 | MdFitnessCenter,
|
|---|
| 17 | MdMonitorWeight,
|
|---|
| 18 | MdAccountBalanceWallet,
|
|---|
| 19 | MdTrendingUp,
|
|---|
| 20 | MdChecklist,
|
|---|
| 21 | MdAdd,
|
|---|
| 22 | } from "react-icons/md";
|
|---|
| 23 |
|
|---|
| 24 | import logo from "../../../assets/logo.png";
|
|---|
| 25 |
|
|---|
| 26 | const navItems = [
|
|---|
| 27 | { title: "Control Center", to: "/dashboard/control-center", icon: MdTune },
|
|---|
| 28 | { title: "Training", to: "/dashboard/training", icon: MdFitnessCenter },
|
|---|
| 29 | { title: "Weight", to: "/dashboard/weight", icon: MdMonitorWeight },
|
|---|
| 30 | { title: "Finance", to: "/dashboard/finance", icon: MdAccountBalanceWallet },
|
|---|
| 31 | { title: "Investing", to: "/dashboard/investing", icon: MdTrendingUp },
|
|---|
| 32 | { title: "Discipline", to: "/dashboard/discipline", icon: MdChecklist },
|
|---|
| 33 | ];
|
|---|
| 34 |
|
|---|
| 35 | const DashboardSidebar = () => {
|
|---|
| 36 | const location = useLocation();
|
|---|
| 37 |
|
|---|
| 38 | return (
|
|---|
| 39 | <Sidebar
|
|---|
| 40 | className="py-6"
|
|---|
| 41 | closeButtonClassName="fixed top-4 right-4"
|
|---|
| 42 | collapsible="none"
|
|---|
| 43 | >
|
|---|
| 44 | <SidebarHeader className="hidden lg:block">
|
|---|
| 45 | <NavLink to="/" className="flex items-center gap-3 px-2">
|
|---|
| 46 | <img src={logo} alt="Trekr" className="h-10 w-auto rounded-2xl" />
|
|---|
| 47 | </NavLink>
|
|---|
| 48 | </SidebarHeader>
|
|---|
| 49 |
|
|---|
| 50 | <SidebarContent className="mt-6">
|
|---|
| 51 | <SidebarMenu>
|
|---|
| 52 | {navItems.map((item) => (
|
|---|
| 53 | <SidebarMenuItem key={item.title}>
|
|---|
| 54 | {(() => {
|
|---|
| 55 | const isActive =
|
|---|
| 56 | location.pathname === item.to ||
|
|---|
| 57 | location.pathname.startsWith(`${item.to}/`);
|
|---|
| 58 |
|
|---|
| 59 | return (
|
|---|
| 60 | <SidebarMenuButton
|
|---|
| 61 | asChild
|
|---|
| 62 | isActive={isActive}
|
|---|
| 63 | className={
|
|---|
| 64 | isActive
|
|---|
| 65 | ? "!bg-green-400 !text-black hover:!bg-green-400 active:!bg-green-400"
|
|---|
| 66 | : ""
|
|---|
| 67 | }
|
|---|
| 68 | >
|
|---|
| 69 | <NavLink
|
|---|
| 70 | to={item.to}
|
|---|
| 71 | className="flex w-full items-center gap-3"
|
|---|
| 72 | >
|
|---|
| 73 | <item.icon
|
|---|
| 74 | className={
|
|---|
| 75 | isActive
|
|---|
| 76 | ? "size-6 shrink-0 text-black"
|
|---|
| 77 | : "size-6 shrink-0"
|
|---|
| 78 | }
|
|---|
| 79 | />
|
|---|
| 80 | <span className={isActive ? "text-black" : ""}>
|
|---|
| 81 | {item.title}
|
|---|
| 82 | </span>
|
|---|
| 83 | </NavLink>
|
|---|
| 84 | </SidebarMenuButton>
|
|---|
| 85 | );
|
|---|
| 86 | })()}
|
|---|
| 87 | </SidebarMenuItem>
|
|---|
| 88 | ))}
|
|---|
| 89 | </SidebarMenu>
|
|---|
| 90 |
|
|---|
| 91 | <div className="mt-6 px-2">
|
|---|
| 92 | <Button
|
|---|
| 93 | variant="secondary"
|
|---|
| 94 | className="w-full justify-start gap-2 !bg-green-400 !text-black hover:!bg-green-500"
|
|---|
| 95 | type="button"
|
|---|
| 96 | >
|
|---|
| 97 | <MdAdd className="size-5" />
|
|---|
| 98 | <span>Add Custom</span>
|
|---|
| 99 | </Button>
|
|---|
| 100 | </div>
|
|---|
| 101 | </SidebarContent>
|
|---|
| 102 | </Sidebar>
|
|---|
| 103 | );
|
|---|
| 104 | };
|
|---|
| 105 |
|
|---|
| 106 | export default DashboardSidebar;
|
|---|