-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSidebar.tsx
68 lines (58 loc) · 1.79 KB
/
Sidebar.tsx
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
"use client";
import { usePathname } from "next/navigation";
import { useMemo } from "react";
import { HiHome } from 'react-icons/hi';
import { BiSearch } from 'react-icons/bi';
import { twMerge } from "tailwind-merge";
import Box from "./ui/Box";
import SidebarItem from "./SidebarItem";
import Library from "./Library";
import { Song } from "@/types";
import usePlayer from "@/hooks/usePlayer";
interface SidebarProps {
children: React.ReactNode;
songs: Song[];
}
const Sidebar: React.FC<SidebarProps> = ({
children,
songs
}) => {
const pathname = usePathname();
const player = usePlayer();
const routes = useMemo(() => [
{
icon: HiHome,
label: 'Home',
active: pathname !== '/search',
href: '/'
},
{
icon: BiSearch,
label: 'Search',
active: pathname === '/search',
href: '/search'
}
], [pathname]);
return (
<div className={twMerge(` flex h-full`, player.activeId && `h-[calc(100%-80px)]`)}>
<div className=" hidden md:flex flex-col gap-y-2 bg-black h-full w-[300px] p-2">
<Box>
<div className=" flex flex-col gap-y-4 px-5 py-4">
{routes.map((item) => (
<SidebarItem
key={item.label}
{...item} />
))}
</div>
</Box>
<Box className=" overflow-y-auto h-full">
<Library songs={songs} />
</Box>
</div>
<main className="h-full flex-1 overflow-y-auto py-2">
{children}
</main>
</div>
);
}
export default Sidebar;