-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up navbar code, add logout button
- Loading branch information
Showing
14 changed files
with
106 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Image from "next/image"; | ||
import NavBarLink from "./NavBarLink"; | ||
import NavBarUserIcon from "./NavBarUserIcon"; | ||
|
||
export default async function NavBar() { | ||
return ( | ||
<div className="bg-primary_default w-full h-[52px] flex flex-row justify-between sticky top-0 px-4"> | ||
<div className="flex flex-row"> | ||
<NavBarLink text="Bemanning" path="/bemanning" /> | ||
</div> | ||
<div className="flex flex-row gap-6 items-center"> | ||
<Image | ||
className="variant-logo" | ||
alt="Variant logo" | ||
src="./images/variant-logo-1.svg" | ||
width="65" | ||
height="16" | ||
/> | ||
<NavBarUserIcon /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import { signOut } from "next-auth/react"; | ||
|
||
export default function Dropdown(props: { initials: string }) { | ||
const [isOpen, setIsOpen] = useState<boolean>(false); | ||
|
||
function toggle() { | ||
setIsOpen((old) => !old); | ||
} | ||
|
||
const transClass = isOpen ? "flex" : "hidden"; | ||
|
||
return ( | ||
<> | ||
<div className="relative"> | ||
<button | ||
className="flex rounded-full border border-white h-9 w-9 overflow-hidden justify-center items-center" | ||
onClick={toggle} | ||
> | ||
<p className="text-white body-small">{props.initials}</p> | ||
</button> | ||
<div | ||
className={`absolute origin-right right-0 bg-primary_l4 w-24 flex flex-col p-4 rounded-sm ${transClass}`} | ||
> | ||
<button | ||
className="hover:opacity-70 text-center " | ||
onClick={() => signOut()} | ||
> | ||
Logg ut | ||
</button> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use client"; | ||
import { usePathname } from "next/navigation"; | ||
|
||
export default function NavBarLink(props: { text: string; path: string }) { | ||
const pathname = usePathname(); | ||
const isCurrentPath = props.path.includes(pathname); | ||
|
||
if (isCurrentPath) { | ||
return ( | ||
<a | ||
className="p-4 body-large-bold text-white flex justify-items-center border-b-[3px] border-secondary_default " | ||
href={`${props.path}`} | ||
> | ||
{props.text} | ||
</a> | ||
); | ||
} else | ||
return ( | ||
<a | ||
className="p-4 body-large text-white opacity-70 flex justify-items-center hover:opacity-100 " | ||
href={`${props.path}`} | ||
> | ||
{props.text} | ||
</a> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { | ||
authOptions, | ||
getCustomServerSession, | ||
} from "@/app/api/auth/[...nextauth]/route"; | ||
import Dropdown from "./NavBarDropdown"; | ||
|
||
export default async function NavBarUserIcon() { | ||
const session = await getCustomServerSession(authOptions); | ||
const initials = | ||
session.user?.name | ||
?.split(" ") | ||
.map((n) => n.charAt(0).toUpperCase()) | ||
.join("") || ""; | ||
|
||
if (session) { | ||
return <Dropdown initials={initials} />; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
frontend/src/components/vibes-buttons/SignInSignOutButton.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.