From c98e4ef28faff9571840256f6ac2bd91c6cc3b87 Mon Sep 17 00:00:00 2001 From: Jonny Date: Mon, 6 Jul 2026 11:54:02 +0200 Subject: [PATCH] feat: add mobile drawer navigation and restyle header --- web/app/layout.tsx | 47 +++++++++++++++++++------- web/components/LogoutButton.tsx | 5 ++- web/components/MobileNav.tsx | 60 +++++++++++++++++++++++++++++++++ web/components/NavLinks.tsx | 26 +++++++++++--- 4 files changed, 120 insertions(+), 18 deletions(-) create mode 100644 web/components/MobileNav.tsx diff --git a/web/app/layout.tsx b/web/app/layout.tsx index d327a43..2f82e23 100644 --- a/web/app/layout.tsx +++ b/web/app/layout.tsx @@ -1,8 +1,11 @@ +import Image from "next/image"; +import Link from "next/link"; import { Inter } from "next/font/google"; import "./globals.css"; import { loadProfile } from "@/lib/auth/profile"; import { NavLinks } from "@/components/NavLinks"; import { LogoutButton } from "@/components/LogoutButton"; +import { MobileNav } from "@/components/MobileNav"; const inter = Inter({ subsets: ["latin"], variable: "--font-inter" }); @@ -18,10 +21,14 @@ export default async function RootLayout({ if (result.status === "missing-profile") { return ( - -
-

Profil nicht gefunden

-

Für deinen Account existiert kein Profil. Bitte wende dich an einen Admin.

+ +
+
+

Profil nicht gefunden

+

+ Für deinen Account existiert kein Profil. Bitte wende dich an einen Admin. +

+
@@ -30,17 +37,33 @@ export default async function RootLayout({ return ( - + {result.status === "ok" && ( -
- - - {result.profile.name} ({result.profile.role}) - - +
+ + Widmann + + +
+ + + {result.profile.name} ({result.profile.role}) + + +
+ + +
+ {result.profile.name} ({result.profile.role}) +
+ +
+ +
+
)} -
{children}
+
{children}
); diff --git a/web/components/LogoutButton.tsx b/web/components/LogoutButton.tsx index ef283b9..8da4a5e 100644 --- a/web/components/LogoutButton.tsx +++ b/web/components/LogoutButton.tsx @@ -1,9 +1,12 @@ import { logout } from "@/app/login/actions"; +import { Button } from "@/components/ui/Button"; export function LogoutButton() { return (
- +
); } diff --git a/web/components/MobileNav.tsx b/web/components/MobileNav.tsx new file mode 100644 index 0000000..5908f3f --- /dev/null +++ b/web/components/MobileNav.tsx @@ -0,0 +1,60 @@ +"use client"; + +import { useEffect, useState } from "react"; + +export function MobileNav({ children }: { children: React.ReactNode }) { + const [open, setOpen] = useState(false); + + useEffect(() => { + if (!open) return; + function onKeyDown(event: KeyboardEvent) { + if (event.key === "Escape") setOpen(false); + } + window.addEventListener("keydown", onKeyDown); + return () => window.removeEventListener("keydown", onKeyDown); + }, [open]); + + return ( +
+ + + {open && ( +
+ + {children} +
+
+ )} + + ); +} diff --git a/web/components/NavLinks.tsx b/web/components/NavLinks.tsx index fd4b41d..904e254 100644 --- a/web/components/NavLinks.tsx +++ b/web/components/NavLinks.tsx @@ -1,12 +1,28 @@ import Link from "next/link"; import { canManageUsers, type Role } from "@/lib/auth/roles"; -export function NavLinks({ role }: { role: Role }) { +export function NavLinks({ + role, + orientation = "vertical", +}: { + role: Role; + orientation?: "vertical" | "horizontal"; +}) { + const layoutClass = orientation === "horizontal" ? "flex flex-row items-center gap-6" : "flex flex-col gap-4"; + return ( -