-
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 (#146)
- Loading branch information
Showing
19 changed files
with
119 additions
and
711 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
File renamed without changes
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 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.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,40 @@ | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import { signOut } from "next-auth/react"; | ||
import { LogOut, User } from "react-feather"; | ||
|
||
export default function NavBarDropdown(props: { initials: string }) { | ||
const [isOpen, setIsOpen] = useState<boolean>(false); | ||
|
||
return ( | ||
<> | ||
<div className="relative"> | ||
<button | ||
className={`flex rounded-full border border-white h-9 min-w-[36px] justify-center items-center ${ | ||
props.initials.length > 3 && "px-1" | ||
}`} | ||
onClick={() => setIsOpen(!isOpen)} | ||
> | ||
<p className="text-white body-small">{props.initials}</p> | ||
</button> | ||
<div | ||
className={`absolute right-0 top-11 rounded-b text-primary_default bg-white flex flex-col w-[138px] shadow-md ${ | ||
!isOpen && "hidden" | ||
}`} | ||
> | ||
<button className="p-2 w-[138px] flex flex-row gap-3 hover:bg-primary_default hover:text-white"> | ||
<User className="w-4 h-4" /> | ||
<p className="body">Min profil</p> | ||
</button> | ||
<button | ||
className="p-2 w-[138px] rounded-b flex flex-row gap-3 hover:bg-primary_default hover:text-white" | ||
onClick={() => signOut()} | ||
> | ||
<LogOut className="w-4 h-4" /> | ||
<p className="body">Logg ut</p> | ||
</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,20 @@ | ||
"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); | ||
|
||
return ( | ||
<a | ||
className={`p-4 flex justify-center items-center text-white ${ | ||
isCurrentPath | ||
? "body-large-bold border-b-[3px] border-secondary_default" | ||
: "body-large opacity-70 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,23 @@ | ||
import { | ||
authOptions, | ||
getCustomServerSession, | ||
} from "@/app/api/auth/[...nextauth]/route"; | ||
import NavBarDropdown from "./NavBarDropdown"; | ||
|
||
export default async function NavBarUserIcon() { | ||
const session = | ||
!process.env.NEXT_PUBLIC_NO_AUTH && | ||
(await getCustomServerSession(authOptions)); | ||
|
||
const initials = | ||
session && session.user && session.user.name | ||
? session.user.name | ||
.split(" ") | ||
.map((name) => name.charAt(0).toUpperCase()) | ||
.join("") | ||
: ""; | ||
|
||
if (session) { | ||
return <NavBarDropdown 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.
Oops, something went wrong.