feat(frontend): Linksseitige Navigation, Seitenanimation, ADHS-freundliche Gruppierung
Ersetzt die horizontale Kopfzeilen-Navigation durch eine feste Sidebar links: gruppiert nach Betrieb / Arbeit / Ernte & Lager / Verwaltung mit Icon+Label je Eintrag, um kognitive Last zu reduzieren. Aktiver Zustand klar farblich hervorgehoben. Mobile Ansicht (Bottom-Nav + FAB) bleibt unveraendert bestehen. Sanfte, kurze Seitenuebergangsanimation (PageTransition, respektiert prefers-reduced-motion ueber motion-safe:) fuer Orientierung ohne Ablenkung. Ausserdem: wiederkehrenden Anzeigefehler in Status-Filtern behoben (Select zeigte den rohen Sentinel-Wert "ALL" statt "Alle Status" an) auf Voelker-, Honigchargen-, Aufgaben-, Koeniginnen- und Bienenstand-Listen. Live in Desktop-, Tablet- und Mobilbreite verifiziert, kein horizontales Overflow.
This commit is contained in:
1 parent
fb2b09a929
commit
ecb3afe1f5
9 files changed
+195
-100
No files matched your search
@@ -2,61 +2,18 @@
|
||||
|
||||
import { ReactNode, useEffect } from "react";
|
||||
import Link from "next/link";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { Hexagon, MoreHorizontal } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Hexagon } from "lucide-react";
|
||||
import { useAuth } from "@/lib/auth/auth-context";
|
||||
import { NotificationBell } from "@/components/notification-bell";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Sidebar } from "./sidebar";
|
||||
import { BottomNav } from "./bottom-nav";
|
||||
import { QuickAddMenu } from "./quick-add-menu";
|
||||
|
||||
const NAV_LINK_CLASS =
|
||||
"shrink-0 rounded-md px-2.5 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground aria-[current=page]:bg-primary/10 aria-[current=page]:text-primary";
|
||||
|
||||
const PRIMARY_LINKS = [
|
||||
{ label: "Dashboard", href: "/dashboard" },
|
||||
{ label: "Bienenstände", href: "/apiaries" },
|
||||
{ label: "Völker", href: "/colonies" },
|
||||
{ label: "Königinnen", href: "/queens" },
|
||||
{ label: "Aufgaben", href: "/tasks" },
|
||||
{ label: "Kalender", href: "/calendar" },
|
||||
{ label: "Honigchargen", href: "/honey-batches" },
|
||||
{ label: "Lager", href: "/storage" },
|
||||
{ label: "Suche", href: "/search" },
|
||||
];
|
||||
|
||||
const MORE_LINKS = [
|
||||
{ label: "Produkte", href: "/products" },
|
||||
{ label: "Abfüllungen", href: "/bottling/new" },
|
||||
{ label: "Inventar", href: "/equipment" },
|
||||
];
|
||||
|
||||
const ADMIN_LINKS = [
|
||||
{ label: "Benutzer", href: "/settings/users" },
|
||||
{ label: "Audit-Log", href: "/settings/audit-log" },
|
||||
];
|
||||
|
||||
function NavLink({ href, label, pathname }: { href: string; label: string; pathname: string }) {
|
||||
return (
|
||||
<Link
|
||||
href={href}
|
||||
aria-current={pathname.startsWith(href) ? "page" : undefined}
|
||||
className={NAV_LINK_CLASS}
|
||||
>
|
||||
{label}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
import { PageTransition } from "./page-transition";
|
||||
|
||||
export default function AppLayout({ children }: { children: ReactNode }) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { user, isLoading, logout } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -70,58 +27,37 @@ export default function AppLayout({ children }: { children: ReactNode }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<header className="flex items-center justify-between gap-3 border-b bg-card px-4 py-2.5">
|
||||
<nav className="flex min-w-0 items-center gap-3 max-sm:gap-2">
|
||||
<Link href="/dashboard" className="flex shrink-0 items-center gap-1.5 font-heading font-semibold">
|
||||
<div className="flex min-h-screen">
|
||||
<Sidebar user={user} />
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<header className="flex items-center justify-between gap-3 border-b bg-card px-4 py-2.5 sm:justify-end sm:px-6">
|
||||
<Link
|
||||
href="/dashboard"
|
||||
className="flex items-center gap-1.5 font-heading font-semibold sm:hidden"
|
||||
>
|
||||
<Hexagon className="size-5 fill-primary/15 text-primary" strokeWidth={2.25} />
|
||||
ApiCore
|
||||
</Link>
|
||||
<div className="hidden min-w-0 items-center gap-1 overflow-x-auto whitespace-nowrap sm:flex">
|
||||
{PRIMARY_LINKS.map((item) => (
|
||||
<NavLink key={item.href} {...item} pathname={pathname} />
|
||||
))}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger
|
||||
render={<Button variant="ghost" size="sm" className="gap-1 text-muted-foreground" />}
|
||||
>
|
||||
<MoreHorizontal className="size-4" />
|
||||
Mehr
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start">
|
||||
{MORE_LINKS.map((item) => (
|
||||
<DropdownMenuItem key={item.href} render={<Link href={item.href} />}>
|
||||
{item.label}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
{user.role === "ADMIN"
|
||||
? ADMIN_LINKS.map((item) => (
|
||||
<DropdownMenuItem key={item.href} render={<Link href={item.href} />}>
|
||||
{item.label}
|
||||
</DropdownMenuItem>
|
||||
))
|
||||
: null}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<div className="flex shrink-0 items-center gap-2 text-sm">
|
||||
<NotificationBell />
|
||||
<span className="hidden max-w-40 truncate text-muted-foreground md:inline">
|
||||
{user.email}
|
||||
</span>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
void logout().then(() => router.push("/login"));
|
||||
}}
|
||||
>
|
||||
Abmelden
|
||||
</Button>
|
||||
</div>
|
||||
</nav>
|
||||
<div className="flex shrink-0 items-center gap-2 text-sm">
|
||||
<NotificationBell />
|
||||
<span className="hidden max-w-40 truncate text-muted-foreground md:inline">
|
||||
{user.email}
|
||||
</span>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
void logout().then(() => router.push("/login"));
|
||||
}}
|
||||
>
|
||||
Abmelden
|
||||
</Button>
|
||||
</header>
|
||||
<div className="flex-1 overflow-y-auto pb-16 sm:pb-0">
|
||||
<PageTransition>{children}</PageTransition>
|
||||
</div>
|
||||
</header>
|
||||
<div className="flex-1 pb-16 sm:pb-0">{children}</div>
|
||||
</div>
|
||||
<BottomNav />
|
||||
<QuickAddMenu />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user