Skip to content

Commit

Permalink
chore(voucher): updated nav-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhart1o1 committed May 17, 2024
1 parent 4310a7d commit 6a5a358
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 33 deletions.
9 changes: 9 additions & 0 deletions apps/voucher/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
@tailwind components;
@tailwind utilities;

*,
*::before,
*::after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}

:root {
--gradient-orange: linear-gradient(0deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1)),
linear-gradient(45deg, #f6a139 0%, #fb5607 100%);
Expand Down
82 changes: 49 additions & 33 deletions apps/voucher/components/nav-bar/navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client"
import React from "react"
import { signOut, useSession } from "next-auth/react"
import { useRouter } from "next/navigation"
import { useRouter, usePathname } from "next/navigation"
import Image from "next/image"
import Link from "next/link"

Expand All @@ -24,8 +24,6 @@ import {
SelectValue,
} from "../select"

import { Separator } from "@/components/separator"

import { useCurrency } from "@/context/currency-context"

const Navigation: React.FC = () => {
Expand Down Expand Up @@ -67,53 +65,70 @@ export default Navigation

const NavMenu = ({ username }: { username: string }) => {
const menuItems = [
{ path: "/create", label: "Create Link" },
{ path: "/user/links", label: "My Links" },
{ path: "/redeem", label: "Redeem" },
{ path: "/create", label: "Create Link", icon: "/create-voucher-outline.svg" },
{ path: "/user/links", label: "My Links", icon: "/links-outline.svg" },
{ path: "/redeem", label: "Redeem", icon: "/redeem-outline.svg" },
]

const pathname = usePathname()

return (
<Sheet>
<SheetTrigger>
<Image src="menu-outline.svg" alt="menu" height={40} priority={true} width={40} />
</SheetTrigger>
<SheetContent className="m-0 p-0">
{username ? (
<>
<SheetHeader className="flex flex-col pl-5 text-left mt-6 justify-center align-middle w-full">
<SheetTitle>{username}</SheetTitle>
</SheetHeader>
<Separator className="mt-5" />
</>
<SheetHeader className="flex flex-col pl-5 text-left mt-6 justify-center align-middle w-full">
<SheetTitle>{username}</SheetTitle>
</SheetHeader>
) : null}
<div
className={`flex flex-col text-left ${
username ? "mt-5" : "mt-20"
} justify-center align-middle w-11/12 border-2 border-secondary m-auto rounded-lg`}
>
{menuItems.map((item, index) => (
<React.Fragment key={item.path}>
<div className="mt-14">
<CurrencySwitcher />
</div>
<div className="flex flex-col align-center gap-1 w-full mt-4">
{menuItems.map((item) => (
<div
className={`flex w-11/12 m-auto justify-center align-middle rounded-md p-2 cursor-pointer ${
pathname === item.path ? "bg-secondary" : "hover:bg-secondary"
}`}
key={item.path}
>
<SheetClose asChild>
<Link className="w-full" href={item.path}>
<div className="w-full hover:bg-secondary p-3 pl-5">{item.label}</div>
<Link
className="w-full flex justify-center align-middle"
href={item.path}
>
<Image
width={25}
height={25}
alt={item.label}
priority={true}
src={item.icon}
></Image>
<div className="w-full pl-5">{item.label}</div>
</Link>
</SheetClose>
{index < menuItems.length - 1 && <Separator />}
</React.Fragment>
</div>
))}
<Separator />
<SheetClose asChild>
<div
className="w-full hover:bg-secondary p-3 pl-5"
onClick={() => signOut({ callbackUrl: "/" })}
>
Log Out
<div className="flex w-11/12 m-auto justify-center hover:bg-secondary p-2 align-middle rounded-md cursor-pointer">
<Image
width={26}
height={26}
alt="logout"
priority={true}
src="/log-out-outline-red.svg"
></Image>
<div
className="w-full text-error pl-5"
onClick={() => signOut({ callbackUrl: "/" })}
>
Log Out
</div>
</div>
</SheetClose>
</div>
<div className="mt-4">
<CurrencySwitcher />
</div>
</SheetContent>
</Sheet>
)
Expand All @@ -123,7 +138,8 @@ export const CurrencySwitcher = () => {
const { currency: selectedCurrency, changeCurrency, currencyList } = useCurrency()

return (
<div className="w-11/12 m-auto">
<div className="w-11/12 m-auto flex gap-1 flex-col">
<div className="text-md font-semibold">Currency</div>
<Select onValueChange={(value) => changeCurrency(value)}>
<SelectTrigger className="text-md">
<SelectValue placeholder={selectedCurrency} />
Expand Down
5 changes: 5 additions & 0 deletions apps/voucher/public/create-voucher-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions apps/voucher/public/links-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/voucher/public/log-out-outline-red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions apps/voucher/public/redeem-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/voucher/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const config: Config = {
"secondary": "#e6ebef",
"white": "#ffffff",
"black": "#000000",
"error": "#dc2626",
},
},
},
Expand Down

0 comments on commit 6a5a358

Please sign in to comment.