feat: expose portal navigation on mobile
This commit is contained in:
1 parent
9089dce74a
commit
0085c721af
2 files changed
+15
-4
No files matched your search
@@ -2,8 +2,12 @@
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { expect, test } from "vitest";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { expect, test, vi } from "vitest";
|
||||
|
||||
vi.mock("next/navigation", () => ({
|
||||
usePathname: () => "/redaktion/alben",
|
||||
}));
|
||||
|
||||
import { PortalShell } from "@/components/layout/portal-shell";
|
||||
import { BrandLogo } from "./logo";
|
||||
@@ -37,6 +41,11 @@ test("keeps masthead controls keyboard-focusable with a paper-coloured focus out
|
||||
// The brand link's accessible name is the section label (aria-label).
|
||||
expect(screen.getByRole("link", { name: /redaktionsarchiv/i }).tagName).toBe("A");
|
||||
expect(screen.getByRole("link", { name: "Alben" }).tagName).toBe("A");
|
||||
const menuTrigger = screen.getByRole("button", { name: /menü öffnen/i });
|
||||
expect(menuTrigger.parentElement?.className).toContain("sm:hidden");
|
||||
fireEvent.click(menuTrigger);
|
||||
expect(screen.getAllByRole("link", { name: "Alben" })).toHaveLength(2);
|
||||
expect(screen.getByRole("navigation", { name: /mobile navigation/i })).toBeTruthy();
|
||||
const styles = readFileSync("src/app/globals.css", "utf8");
|
||||
expect(styles).toContain(".portal-masthead :focus-visible");
|
||||
expect(styles).toContain("outline-color: var(--paper)");
|
||||
|
||||
@@ -4,6 +4,7 @@ import Link from "next/link";
|
||||
|
||||
import { BrandLogo } from "@/components/brand/logo";
|
||||
import { LogoutButton } from "@/components/layout/logout-button";
|
||||
import { MobilePortalMenu } from "@/components/layout/mobile-portal-menu";
|
||||
import { ThemeToggle } from "@/components/theme-toggle";
|
||||
|
||||
export type NavItem = { href: string; label: string };
|
||||
@@ -30,7 +31,7 @@ export function PortalShell({
|
||||
return (
|
||||
<div className="min-h-screen bg-background flex flex-col">
|
||||
<header className="sticky top-0 z-50 w-full border-b border-border/40 bg-background/80 backdrop-blur-md transition-colors duration-300">
|
||||
<div className="flex h-16 items-center justify-between px-6 lg:px-12">
|
||||
<div className="flex h-16 items-center justify-between px-4 sm:px-6 lg:px-12">
|
||||
<Link aria-label={sectionLabel} className="flex items-center gap-2 transition-opacity hover:opacity-80" href={brandHref}>
|
||||
<div className="flex items-center"><BrandLogo /></div>
|
||||
</Link>
|
||||
@@ -47,10 +48,11 @@ export function PortalShell({
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="hidden items-center gap-4 sm:flex">
|
||||
<ThemeToggle />
|
||||
<LogoutButton />
|
||||
</div>
|
||||
<MobilePortalMenu nav={nav} sectionLabel={sectionLabel} />
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
Reference in new issue
Block a user