Skip to content

Commit

Permalink
feat(layout): add Navbar component
Browse files Browse the repository at this point in the history
  • Loading branch information
ladunjexa committed Apr 28, 2024
1 parent 3de00a5 commit 02e881e
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
69 changes: 69 additions & 0 deletions components/layout/mobile-nav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"use client";

import React from "react";
import { Sheet, SheetClose, SheetContent, SheetTrigger } from "@/components/ui/sheet";
import Image from "next/image";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { sidebarLinks } from "@/constants";
import { cn } from "@/lib/utils";

type Props = {};

const MobileNav = (props: Props) => {
const pathname = usePathname();
return (
<section className="w-full max-w-[264px]">
<Sheet>
<SheetTrigger asChild>
<Image
src={"/icons/hamburger.svg"}
width={36}
height={36}
alt="hamburger icon"
className="cursor-pointer sm:hidden"
/>
</SheetTrigger>
<SheetContent side="left" className="border-none bg-dark-1">
<Link href="/" className="flex items-center gap-1">
<Image
src={"/icons/logo.svg"}
width={32}
height={32}
alt="Yoom"
className="max-sm:size-10"
/>
<p className="text-[26px] font-extrabold text-white">Yoom</p>
</Link>

<div className="flex h-[calc(100vh-72px)] flex-col justify-between overflow-y-auto">
<SheetClose asChild>
<section className="flex h-full flex-col gap-6 pt-16 text-white">
{sidebarLinks.map(link => {
const isActive = pathname === link.route || pathname.startsWith(`${link.route}/`);

return (
<SheetClose asChild key={link.route}>
<Link
key={link.label}
href={link.route}
className={cn("flex gap-4 items-center p-4 rounded-lg justify-start", {
"bg-blue-1": isActive,
})}
>
<Image src={link.imgUrl} alt={link.label} width={24} height={24} />
<p className="font-semibold">{link.label}</p>
</Link>
</SheetClose>
);
})}
</section>
</SheetClose>
</div>
</SheetContent>
</Sheet>
</section>
);
};

export default MobileNav;
23 changes: 22 additions & 1 deletion components/layout/navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import Image from "next/image";
import Link from "next/link";
import React from "react";
import MobileNav from "./mobile-nav";

type Props = {};

const Navbar = (props: Props) => {
return <div>Navbar</div>;
return (
<nav className="flex-between fixed z-50 w-full bg-dark-1 px-6 py-4 lg:px-10">
<Link href="/" className="flex items-center gap-1">
<Image
src={"/icons/logo.svg"}
width={32}
height={32}
alt="Yoom"
className="max-sm:size-10"
/>
<p className="text-[26px] font-extrabold text-white max-sm:hidden">Yoom</p>
</Link>

<div className="flex-between gap-5">
{/* Clerk Magic */}
<MobileNav />
</div>
</nav>
);
};

export default Navbar;

0 comments on commit 02e881e

Please # to comment.