Skip to content

Commit

Permalink
fix header
Browse files Browse the repository at this point in the history
  • Loading branch information
fuoridallarete committed Feb 22, 2024
1 parent 5455927 commit 78edef7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Dropdown: FC<DropdownProps> = ({
<div
tabIndex={0}
role="button"
className="btn m-1 border-0 bg-transparent hover:bg-transparent"
className="btn m-1 border-0 p-0 bg-transparent hover:bg-transparent"
>
{renderButton}
</div>
Expand Down
54 changes: 1 addition & 53 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { MAIN_LOGIN_PROVIDER } from "@/pages/api/auth/[...nextauth]";
import { signIn, signOut, useSession } from "next-auth/react";
import { ThemeSelector, Dropdown, DropdownProps } from "@/components";
import { ThemeSelector, Dropdown } from "@/components";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/router";
import { useMemo } from "react";

export const Header = () => {
const { data: session, status } = useSession();
const router = useRouter();

const navDropdownItems = useNavDropdownItems();

const handleLogout = async () => {
await signOut();
};
Expand All @@ -21,27 +18,6 @@ export const Header = () => {
<header>
<div className="navbar bg-base-100">
<div className="navbar-start">
<Dropdown
renderButton={
<label htmlFor="menu" className="btn btn-ghost lg:hidden">
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M4 6h16M4 12h8m-8 6h16"
/>
</svg>
</label>
}
items={navDropdownItems}
/>
<Link href="/" className="btn btn-ghost normal-case text-xl">
GitHub Stats
</Link>
Expand Down Expand Up @@ -113,31 +89,3 @@ export const Header = () => {
</>
);
};

const useNavDropdownItems = () => {
const router = useRouter();
const { data: session, status } = useSession();

const navDropdownItems = useMemo(() => {
const items: DropdownProps["items"] = [
{
renderItem: "Home",
onClick: () => {
router.push("/");
},
},
];
if (status === "authenticated") {
items.push({
renderItem: "Stats",
onClick: () => {
if (session) {
router.push(`/stats/${session.user.login}`);
}
},
});
}
return items;
}, [status, router, session]);
return navDropdownItems;
};

0 comments on commit 78edef7

Please sign in to comment.