Skip to content

Commit

Permalink
Merge pull request #267 from chingu-x/fix/dropdown-menu-styles
Browse files Browse the repository at this point in the history
Fix/fix dropdown menu styles
  • Loading branch information
Dan-Y-Ko authored Sep 27, 2024
2 parents 52ed5b7 + 8d7db4d commit 1d6be1b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
50 changes: 33 additions & 17 deletions src/components/navbar/DropDown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { ChevronDownIcon } from "@heroicons/react/24/outline";
import DropDownLink from "./DropDownLink";
import Link from "next/link";
import Button from "@/components/Button";
import { useAppDispatch, useUser } from "@/store/hooks";
import { clientSignOut } from "@/store/features/auth/authSlice";
Expand All @@ -14,12 +14,18 @@ export default function DropDown({ openState }: { openState?: boolean }) {
const activeVoyage = allVoyages?.find(
(item) => item.voyageTeam.voyage.status.name === "Active",
);
const currentVoyage =
activeVoyage?.voyageTeam.name ??
"Please join a voyage to see your status information.";

const currentVoyage = activeVoyage?.voyageTeam.name
? `Team - Tier ${activeVoyage.voyageTeam.name
.split("-")[1]
.split("tier")[1]
.toUpperCase()} ${activeVoyage.voyageTeam.name
.split("-")[0]
.toUpperCase()}`
: "Please join a voyage to see your status information.";
const closed = "hidden";
const open =
"absolute z-[1] w-44 p-4 [&>*]:mt-2 mt-6 shadow bg-base-100 right-0 border border-neutral rounded-2xl";
"absolute flex flex-col gap-5 z-[1] w-[250px] p-5 bottom-100 translate-y-[15%] shadow-md bg-base-200 right-0 border border-base-100 rounded-2xl";

async function handleClick() {
const [res, error] = await serverSignOut();
Expand All @@ -35,7 +41,7 @@ export default function DropDown({ openState }: { openState?: boolean }) {
}
}

const handleDropDownClick = (event: React.MouseEvent<HTMLUListElement>) => {
const handleDropDownClick = (event: React.MouseEvent<HTMLDivElement>) => {
event.stopPropagation();
};

Expand All @@ -47,35 +53,45 @@ export default function DropDown({ openState }: { openState?: boolean }) {
>
<ChevronDownIcon className="w-4 cursor-pointer text-base-300" />
</label>
<ul
<div
tabIndex={0}
className={openState ? open : closed}
onClick={handleDropDownClick}
>
<li className="rounded-lg bg-secondary-content p-2 text-xs [&>*]:m-1">
<p className="text-xs text-neutral">My Status:</p>
{currentVoyage ? (
<p className="border border-transparent font-semibold text-base-300">
<div className="rounded-lg bg-secondary-content p-2 text-xs [&>*]:m-1">
<p className="text-[10px] font-medium text-neutral-focus">
My Voyage:
</p>
{activeVoyage?.voyageTeam.name ? (
<p className="border border-transparent text-base font-medium text-base-300">
{currentVoyage}
</p>
) : (
<p className="border-transparent font-semibold text-base-300">
{currentVoyage}
</p>
)}
</li>
<DropDownLink title="Settings" href="/hello404" />
</div>
<Link href="/hello404">
<Button
type="button"
variant="link"
size="lg"
className="m-0 flex w-full justify-start p-2 hover:bg-base-100 hover:text-base-300"
>
Settings
</Button>
</Link>
<Button
title="signout"
type="button"
onClick={handleClick}
variant="link"
size={"lg"}
className="m-0 flex w-full justify-start p-2 hover:bg-neutral-content hover:text-base-300"
size="lg"
className="m-0 flex w-full justify-start p-2 hover:bg-base-100 hover:text-base-300"
>
Sign Out
</Button>
</ul>
</div>
</div>
);
}
19 changes: 0 additions & 19 deletions src/components/navbar/DropDownLink.tsx

This file was deleted.

0 comments on commit 1d6be1b

Please sign in to comment.