-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathSidebar.tsx
More file actions
79 lines (78 loc) · 3.07 KB
/
Sidebar.tsx
File metadata and controls
79 lines (78 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React, { JSX, useContext } from "react";
import { Link } from "react-router-dom";
import { AppContext } from "../app-context.jsx";
import { FireproofHome } from "./FireproofHome.jsx";
import { TenantSelector } from "./TenantSelector.jsx";
//
export function Sidebar({ sideBarComponent, title, newUrl }: { sideBarComponent: JSX.Element; title?: string; newUrl?: string }) {
const { isSidebarOpen, setIsSidebarOpen } = useContext(AppContext).sideBar;
return (
<div
className={`fixed md:static inset-0 bg-fp-bg-00 z-40 w-[280px] transform transition-transform duration-300 ease-in-out ${
isSidebarOpen ? "translate-x-0" : "-translate-x-full"
} md:translate-x-0 flex flex-col border-r border-fp-dec-00 overflow-hidden`}
>
<div className="flex h-[60px] items-center px-5 flex-shrink-0 justify-between">
<div className="flex items-center gap-2 font-semibold">
<FireproofHome />
<Link to="" onClick={() => setIsSidebarOpen?.(false)}>
<span>Fireproof Connect</span>
</Link>
</div>
{/* Close button for mobile */}
<button onClick={() => setIsSidebarOpen?.(false)} className="md:hidden p-2 rounded-md bg-[--muted] hover:bg-[--muted]/80">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
</div>
<TenantSelector />
<div className="flex-1 overflow-y-auto">
<nav className="grid gap-4 px-6 py-4 text-sm font-medium">
{title && (
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<span className="font-semibold">{title}</span>
</div>
{newUrl && (
<Link
className="inline-flex h-8 items-center justify-center rounded bg-[--accent] px-3 text-accent-foreground transition-colors hover:bg-[--accent]/80"
to={newUrl}
onClick={() => setIsSidebarOpen?.(false)}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="h-4 w-4"
>
<path d="M5 12h14"></path>
<path d="M12 5v14"></path>
</svg>
</Link>
)}
</div>
)}
<div className="grid gap-2">{sideBarComponent}</div>
</nav>
</div>
</div>
);
}