Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up navbar code, add logout button #146

Merged
merged 7 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"prettier:ci": "prettier --check . "
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.9",
"@mui/material": "^5.14.10",
"@types/node": "20.5.9",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./globals.css";
import Head from "next/head";
import AppProviders from "../components/AppProviders";
import NavBar from "@/components/NavBar";

export default function RootLayout({
children,
Expand All @@ -17,7 +17,8 @@ export default function RootLayout({
/>
</Head>
<body>
<AppProviders>{children}</AppProviders>
<NavBar />
{children}
</body>
</html>
);
Expand Down
17 changes: 0 additions & 17 deletions frontend/src/components/AppProviders.tsx

This file was deleted.

23 changes: 23 additions & 0 deletions frontend/src/components/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Image from "next/image";
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
import NavBarLink from "./NavBarLink";
import NavBarUserIcon from "./NavBarUserIcon";

export default async function NavBar() {
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
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"
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
width="65"
height="16"
/>
<NavBarUserIcon />
</div>
</div>
);
}
42 changes: 42 additions & 0 deletions frontend/src/components/NavBarDropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"use client";
import React, { useState } from "react";
import { signOut } from "next-auth/react";
import { LogOut, User } from "react-feather";

export default function Dropdown(props: { initials: string }) {
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
const [isOpen, setIsOpen] = useState<boolean>(false);

function toggle() {
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
setIsOpen((old) => !old);
}

const transClass = isOpen ? "flex" : "hidden";
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
<div className="relative">
<button
className="flex rounded-full border border-white h-9 w-9 overflow-hidden justify-center items-center"
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
onClick={toggle}
>
<p className="text-white body-small">{props.initials}</p>
</button>
<div
className={`absolute origin-right right-0 top-11 rounded text-primary_default bg-white flex flex-col w-[138px] shadow-[0_4px_4px_0_rgba(66,61,137,0.10)] ${transClass}`}
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
>
<button className="text-center p-2 w-[138px] rounded flex flex-row gap-3 align-middle hover:bg-primary_default hover:text-white">
<User className=" w-4 h-4" />
<p className="body">Min profil</p>
</button>
<button
className="text-center p-2 w-[138px] rounded flex flex-row gap-3 align-middle hover:bg-primary_default hover:text-white"
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
onClick={() => signOut()}
>
<LogOut className=" w-4 h-4" />
<p className="body">Logg ut</p>
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
</button>
</div>
</div>
</>
);
}
26 changes: 26 additions & 0 deletions frontend/src/components/NavBarLink.tsx
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) {
mathildehaugum marked this conversation as resolved.
Show resolved Hide resolved
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>
);
}
23 changes: 23 additions & 0 deletions frontend/src/components/NavBarUserIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
authOptions,
getCustomServerSession,
} from "@/app/api/auth/[...nextauth]/route";
import Dropdown from "./NavBarDropdown";

export default async function NavBarUserIcon() {
const session = process.env.NEXT_PUBLIC_NO_AUTH
? null
: await getCustomServerSession(authOptions);

const initials =
session && session.user && session.user.name
? session.user.name
?.split(" ")
.map((n) => n.charAt(0).toUpperCase())
.join("")
: "";

if (session) {
return <Dropdown initials={initials} />;
}
}
15 changes: 0 additions & 15 deletions frontend/src/components/PageLayout.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions frontend/src/components/ThemeRegistry/ThemeRegistry.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions frontend/src/components/ThemeRegistry/theme.ts

This file was deleted.

44 changes: 0 additions & 44 deletions frontend/src/components/VibesNavBar.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions frontend/src/components/VibesNavBarTabs.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions frontend/src/components/vibes-buttons/SignInButton.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions frontend/src/components/vibes-buttons/SignInSignOutButton.tsx

This file was deleted.

Loading