Files
frigate/web/src/components/navigation/Sidebar.tsx
T

51 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-02-27 14:39:05 -07:00
import Logo from "../Logo";
import NavItem from "./NavItem";
2024-03-04 16:18:30 -07:00
import { CameraGroupSelector } from "../filter/CameraGroupSelector";
import { Link, useMatch } from "react-router-dom";
import GeneralSettings from "../menu/GeneralSettings";
import AccountSettings from "../menu/AccountSettings";
2024-04-11 14:54:09 -06:00
import useNavigation from "@/hooks/use-navigation";
2024-07-09 14:36:55 -05:00
import { baseUrl } from "@/api/baseUrl";
import { useMemo } from "react";
2024-02-27 14:39:05 -07:00
function Sidebar() {
2024-07-09 14:36:55 -05:00
const basePath = useMemo(() => new URL(baseUrl).pathname, []);
2024-03-04 16:18:30 -07:00
const isRootMatch = useMatch("/");
const isBasePathMatch = useMatch(basePath);
2024-04-11 14:54:09 -06:00
const navbarLinks = useNavigation();
2024-02-27 14:39:05 -07:00
return (
<aside className="scrollbar-container scrollbar-hidden absolute inset-y-0 left-0 z-10 flex w-[52px] flex-col justify-between overflow-y-auto border-r border-secondary-highlight bg-background_alt py-4">
2024-02-27 14:39:05 -07:00
<span tabIndex={0} className="sr-only" />
2024-05-14 10:06:44 -05:00
<div className="flex w-full flex-col items-center gap-0">
<Link to="/">
<Logo className="mb-6 h-8 w-8" />
</Link>
2024-03-05 17:39:37 -07:00
{navbarLinks.map((item) => {
const showCameraGroups =
(isRootMatch || isBasePathMatch) && item.id === 1;
2024-03-05 17:39:37 -07:00
return (
<div key={item.id}>
<NavItem
className={`mx-[10px] ${showCameraGroups ? "mb-2" : "mb-4"}`}
2024-04-11 14:54:09 -06:00
item={item}
2024-03-05 17:39:37 -07:00
Icon={item.icon}
/>
{showCameraGroups && <CameraGroupSelector className="mb-4" />}
</div>
);
})}
2024-02-27 14:39:05 -07:00
</div>
2024-05-14 10:06:44 -05:00
<div className="mb-8 flex flex-col items-center gap-4">
<GeneralSettings />
<AccountSettings />
</div>
2024-02-27 14:39:05 -07:00
</aside>
);
}
export default Sidebar;