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 { readFileSync } from "node:fs";
|
||||||
|
|
||||||
import { render, screen } from "@testing-library/react";
|
import { fireEvent, render, screen } from "@testing-library/react";
|
||||||
import { expect, test } from "vitest";
|
import { expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
vi.mock("next/navigation", () => ({
|
||||||
|
usePathname: () => "/redaktion/alben",
|
||||||
|
}));
|
||||||
|
|
||||||
import { PortalShell } from "@/components/layout/portal-shell";
|
import { PortalShell } from "@/components/layout/portal-shell";
|
||||||
import { BrandLogo } from "./logo";
|
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).
|
// 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: /redaktionsarchiv/i }).tagName).toBe("A");
|
||||||
expect(screen.getByRole("link", { name: "Alben" }).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");
|
const styles = readFileSync("src/app/globals.css", "utf8");
|
||||||
expect(styles).toContain(".portal-masthead :focus-visible");
|
expect(styles).toContain(".portal-masthead :focus-visible");
|
||||||
expect(styles).toContain("outline-color: var(--paper)");
|
expect(styles).toContain("outline-color: var(--paper)");
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Link from "next/link";
|
|||||||
|
|
||||||
import { BrandLogo } from "@/components/brand/logo";
|
import { BrandLogo } from "@/components/brand/logo";
|
||||||
import { LogoutButton } from "@/components/layout/logout-button";
|
import { LogoutButton } from "@/components/layout/logout-button";
|
||||||
|
import { MobilePortalMenu } from "@/components/layout/mobile-portal-menu";
|
||||||
import { ThemeToggle } from "@/components/theme-toggle";
|
import { ThemeToggle } from "@/components/theme-toggle";
|
||||||
|
|
||||||
export type NavItem = { href: string; label: string };
|
export type NavItem = { href: string; label: string };
|
||||||
@@ -30,7 +31,7 @@ export function PortalShell({
|
|||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-background flex flex-col">
|
<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">
|
<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}>
|
<Link aria-label={sectionLabel} className="flex items-center gap-2 transition-opacity hover:opacity-80" href={brandHref}>
|
||||||
<div className="flex items-center"><BrandLogo /></div>
|
<div className="flex items-center"><BrandLogo /></div>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -47,10 +48,11 @@ export function PortalShell({
|
|||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
<div className="flex items-center gap-4">
|
<div className="hidden items-center gap-4 sm:flex">
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
<LogoutButton />
|
<LogoutButton />
|
||||||
</div>
|
</div>
|
||||||
|
<MobilePortalMenu nav={nav} sectionLabel={sectionLabel} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
Reference in new issue
Block a user