diff options
| author | MohamedBassem <me@mbassem.com> | 2024-02-09 15:32:04 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-02-09 15:32:04 +0000 |
| commit | 4fae8f04f546d2b3f6053870d93385fa36af4742 (patch) | |
| tree | fbf91f3c3c3d2bd85e9e4cfc8200d275a78fb700 /packages/web/app/dashboard/components | |
| parent | b25f17509e704eb41523bf455a33804cabf8aaca (diff) | |
| download | karakeep-4fae8f04f546d2b3f6053870d93385fa36af4742.tar.zst | |
[ui] Adding the favourites and archive pages
Diffstat (limited to 'packages/web/app/dashboard/components')
| -rw-r--r-- | packages/web/app/dashboard/components/Sidebar.tsx | 39 | ||||
| -rw-r--r-- | packages/web/app/dashboard/components/SidebarItem.tsx | 30 |
2 files changed, 46 insertions, 23 deletions
diff --git a/packages/web/app/dashboard/components/Sidebar.tsx b/packages/web/app/dashboard/components/Sidebar.tsx index c2abe1e1..3b4e1649 100644 --- a/packages/web/app/dashboard/components/Sidebar.tsx +++ b/packages/web/app/dashboard/components/Sidebar.tsx @@ -2,27 +2,8 @@ import { Button } from "@/components/ui/button"; import { authOptions } from "@/lib/auth"; import { Archive, MoreHorizontal, Star, Tag, Home, Brain } from "lucide-react"; import { getServerSession } from "next-auth"; -import Link from "next/link"; import { redirect } from "next/navigation"; - -function SidebarItem({ - name, - logo, - path, -}: { - name: string; - logo: React.ReactNode; - path: string; -}) { - return ( - <li className="rounded-lg px-3 py-2 hover:bg-slate-100"> - <Link href={path} className="flex w-full space-x-2"> - {logo} - <span className="my-auto"> {name} </span> - </Link> - </li> - ); -} +import SidebarItem from "./SidebarItem"; export default async function Sidebar() { const session = await getServerSession(authOptions); @@ -39,9 +20,21 @@ export default async function Sidebar() { <hr /> <div> <ul className="mt-5 space-y-2 text-sm font-medium"> - <SidebarItem logo={<Home />} name="Home" path="#" /> - <SidebarItem logo={<Star />} name="Favourites" path="#" /> - <SidebarItem logo={<Archive />} name="Archived" path="#" /> + <SidebarItem + logo={<Home />} + name="Home" + path="/dashboard/bookmarks" + /> + <SidebarItem + logo={<Star />} + name="Favourites" + path="/dashboard/bookmarks/favourites" + /> + <SidebarItem + logo={<Archive />} + name="Archive" + path="/dashboard/bookmarks/archive" + /> <SidebarItem logo={<Tag />} name="Tags" path="#" /> </ul> </div> diff --git a/packages/web/app/dashboard/components/SidebarItem.tsx b/packages/web/app/dashboard/components/SidebarItem.tsx new file mode 100644 index 00000000..e6a00d72 --- /dev/null +++ b/packages/web/app/dashboard/components/SidebarItem.tsx @@ -0,0 +1,30 @@ +"use client"; + +import { cn } from "@/lib/utils"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; + +export default function SidebarItem({ + name, + logo, + path, +}: { + name: string; + logo: React.ReactNode; + path: string; +}) { + const currentPath = usePathname(); + return ( + <li + className={cn( + "rounded-lg hover:bg-slate-100", + path == currentPath ? "bg-slate-100" : "", + )} + > + <Link href={path} className="flex w-full space-x-2 px-3 py-2"> + {logo} + <span className="my-auto"> {name} </span> + </Link> + </li> + ); +} |
