Skip to content

Commit

Permalink
feature: Introduce a separate sidebar for the mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Feb 22, 2024
1 parent cd2e65e commit 4e1ea0a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
24 changes: 24 additions & 0 deletions packages/web/app/dashboard/components/ModileSidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import MobileSidebarItem from "./ModileSidebarItem";
import { Archive, Star, Tag, PackageOpen, Settings } from "lucide-react";
import SidebarProfileOptions from "./SidebarProfileOptions";

export default async function MobileSidebar() {
return (
<aside className="w-full">
<ul className="flex justify-between space-x-2 border-b-black bg-gray-100 px-5 py-2 pt-5">
<MobileSidebarItem logo={<PackageOpen />} path="/dashboard/bookmarks" />
<MobileSidebarItem
logo={<Star />}
path="/dashboard/bookmarks/favourites"
/>
<MobileSidebarItem
logo={<Archive />}
path="/dashboard/bookmarks/archive"
/>
<MobileSidebarItem logo={<Tag />} path="/dashboard/tags" />
<MobileSidebarItem logo={<Settings />} path="/dashboard/settings" />
<SidebarProfileOptions />
</ul>
</aside>
);
}
27 changes: 27 additions & 0 deletions packages/web/app/dashboard/components/ModileSidebarItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use client";

import { cn } from "@/lib/utils";
import Link from "next/link";
import { usePathname } from "next/navigation";

export default function MobileSidebarItem({
logo,
path,
}: {
logo: React.ReactNode;
path: string;
}) {
const currentPath = usePathname();
return (
<li
className={cn(
"flex w-full rounded-lg hover:bg-gray-50",
path == currentPath ? "bg-gray-50" : "",
)}
>
<Link href={path} className="mx-auto px-3 py-2">
{logo}
</Link>
</li>
);
}
2 changes: 1 addition & 1 deletion packages/web/app/dashboard/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default async function Sidebar() {
/>
</ul>
</div>
<div className="mt-auto flex justify-between">
<div className="mt-auto flex justify-between justify-self-end">
<div className="my-auto"> {session.user.name} </div>
<SidebarProfileOptions />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/web/app/dashboard/components/SidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function SidebarItem({
<li
className={cn(
"rounded-lg hover:bg-slate-100",
path == currentPath ? "bg-slate-100" : "",
path == currentPath ? "bg-gray-50" : "",
)}
>
<Link href={path} className="flex w-full space-x-2 px-3 py-2">
Expand Down
14 changes: 11 additions & 3 deletions packages/web/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Separator } from "@/components/ui/separator";
import MobileSidebar from "./components/ModileSidebar";
import Sidebar from "./components/Sidebar";

export default async function Dashboard({
Expand All @@ -6,11 +8,17 @@ export default async function Dashboard({
children: React.ReactNode;
}>) {
return (
<div className="flex h-screen w-screen">
<div className="flex-none">
<div className="flex h-screen w-screen flex-col sm:flex-row">
<div className="hidden flex-none sm:flex">
<Sidebar />
</div>
<main className="flex-1 overflow-y-auto bg-gray-100">{children}</main>
<main className="flex-1 overflow-y-auto bg-gray-100">
<div className="block w-full sm:hidden">
<MobileSidebar />
<Separator />
</div>
{children}
</main>
</div>
);
}

0 comments on commit 4e1ea0a

Please sign in to comment.