feat: unify admin dashboard shell, add logout button
Admin used an undefined `.portal-shell` class plus the landing-page `.masthead` markup, so the layout had no background/min-height and CSS "kackte rein". Generalize PortalShell to take brand/nav props, switch admin/layout.tsx to it (dark portal masthead + BrandLogo + admin nav), and pass the editorial nav from redaktion/layout.tsx so both surfaces share one shell. Add a LogoutButton client component (Better Auth signOut → hard navigate to /anmelden) rendered into the masthead. Style the admin content that had no rules: `.content-section dl/dt/dd` mirrors `.editorial-section dl` (admin detail page), `.editorial-list` mirrors `.billing-editorial-list` (Redaktionen index, replacing browser bullets), `.portal-signout` for the dark masthead. Mobile: meta wraps, dl goes single column. Update logo.test.tsx to PortalShell's new required props. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
23b251be7c
commit
7aeceee078
7 files changed
+187
-31
No files matched your search
+13
-15
@@ -1,27 +1,25 @@
|
|||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import Link from "next/link";
|
|
||||||
|
|
||||||
|
import { PortalShell } from "@/components/layout/portal-shell";
|
||||||
import { requireAdmin } from "@/modules/auth/principal";
|
import { requireAdmin } from "@/modules/auth/principal";
|
||||||
|
|
||||||
export default async function AdminLayout({ children }: Readonly<{ children: ReactNode }>) {
|
export default async function AdminLayout({ children }: Readonly<{ children: ReactNode }>) {
|
||||||
await requireAdmin(new Headers(await headers()));
|
await requireAdmin(new Headers(await headers()));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="portal-shell">
|
<PortalShell
|
||||||
<header className="masthead">
|
brandHref="/admin/redaktionen"
|
||||||
<Link className="wordmark" href="/admin">
|
sectionLabel="Administration"
|
||||||
Leon Tonhäuser
|
nav={[
|
||||||
</Link>
|
{ href: "/admin/redaktionen", label: "Redaktionen" },
|
||||||
<span className="section-label">Administration</span>
|
{ href: "/admin/abrechnungen", label: "Abrechnungen" },
|
||||||
</header>
|
{ href: "/admin/audit", label: "Audit" },
|
||||||
<nav aria-label="Administration">
|
]}
|
||||||
<Link href="/admin/redaktionen">Redaktionen</Link>
|
mainClassName=""
|
||||||
<Link href="/admin/abrechnungen">Abrechnungen</Link>
|
>
|
||||||
<Link href="/admin/audit">Audit</Link>
|
|
||||||
</nav>
|
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</PortalShell>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ export default async function EditorialsPage() {
|
|||||||
{editorials.length === 0 ? (
|
{editorials.length === 0 ? (
|
||||||
<p>Noch keine Redaktionen registriert.</p>
|
<p>Noch keine Redaktionen registriert.</p>
|
||||||
) : (
|
) : (
|
||||||
<ul>
|
<ul className="editorial-list">
|
||||||
{editorials.map((editorial) => (
|
{editorials.map((editorial) => (
|
||||||
<li key={editorial.id}>
|
<li key={editorial.id}>
|
||||||
<a href={`/admin/redaktionen/${editorial.id}`}>{editorial.name}</a>
|
<a href={`/admin/redaktionen/${editorial.id}`}>{editorial.name}</a>
|
||||||
|
|||||||
+92
-2
@@ -412,6 +412,31 @@ a {
|
|||||||
text-underline-offset: 0.28em;
|
text-underline-offset: 0.28em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.portal-signout {
|
||||||
|
border: 1px solid #d4d4d4;
|
||||||
|
border-radius: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--paper);
|
||||||
|
cursor: pointer;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.1em;
|
||||||
|
padding: 0.4rem 0.8rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
transition: background-color 140ms ease, color 140ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.portal-signout:hover:not(:disabled) {
|
||||||
|
background: var(--paper);
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.portal-signout:disabled {
|
||||||
|
cursor: wait;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
.portal-masthead :focus-visible {
|
.portal-masthead :focus-visible {
|
||||||
outline-color: var(--paper);
|
outline-color: var(--paper);
|
||||||
}
|
}
|
||||||
@@ -675,21 +700,29 @@ a {
|
|||||||
|
|
||||||
.portal-masthead-meta {
|
.portal-masthead-meta {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
row-gap: 1rem;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.portal-signout {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.editorial-title-row {
|
.editorial-title-row {
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1.25rem;
|
gap: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editorial-section dl {
|
.editorial-section dl,
|
||||||
|
.content-section dl {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editorial-section dd {
|
.editorial-section dd,
|
||||||
|
.content-section dd {
|
||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1065,6 +1098,63 @@ a {
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mirrors `.editorial-section dl` so the admin detail page's `<dl>` (which
|
||||||
|
lives under `.content-section`, not `.editorial-section`) gets the same
|
||||||
|
grid + metadata treatment without duplicating markup. */
|
||||||
|
.content-section dl {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr);
|
||||||
|
gap: 0.85rem 1.5rem;
|
||||||
|
max-width: 48rem;
|
||||||
|
margin: 2rem 0 0;
|
||||||
|
padding-top: 1.25rem;
|
||||||
|
border-top: 1px solid var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-section dt {
|
||||||
|
color: var(--metadata);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-section dd {
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.45;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mirrors `.billing-editorial-list` — reused by the admin "Redaktionen"
|
||||||
|
list so it reads like the billing index without a parallel class. */
|
||||||
|
.editorial-list {
|
||||||
|
display: grid;
|
||||||
|
gap: 1.25rem;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editorial-list li {
|
||||||
|
padding-bottom: 1.25rem;
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.editorial-list a {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
font-weight: 650;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editorial-list a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 0.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editorial-list p {
|
||||||
|
margin: 0.35rem 0 0;
|
||||||
|
color: var(--metadata);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
.billing-editorial-list {
|
.billing-editorial-list {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 1.25rem;
|
gap: 1.25rem;
|
||||||
|
|||||||
@@ -7,5 +7,17 @@ import { requireEditorial } from "./access";
|
|||||||
export default async function EditorialLayout({ children }: Readonly<{ children: ReactNode }>) {
|
export default async function EditorialLayout({ children }: Readonly<{ children: ReactNode }>) {
|
||||||
await requireEditorial();
|
await requireEditorial();
|
||||||
|
|
||||||
return <PortalShell>{children}</PortalShell>;
|
return (
|
||||||
}
|
<PortalShell
|
||||||
|
brandHref="/redaktion/alben"
|
||||||
|
sectionLabel="Redaktionsarchiv"
|
||||||
|
nav={[
|
||||||
|
{ href: "/redaktion/alben", label: "Alben" },
|
||||||
|
{ href: "/redaktion/nutzungen", label: "Nutzungen" },
|
||||||
|
{ href: "/redaktion/profil", label: "Profil" },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</PortalShell>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -21,12 +21,17 @@ test("uses each supplied logo's true intrinsic dimensions", () => {
|
|||||||
|
|
||||||
test("keeps masthead controls keyboard-focusable with a paper-coloured focus outline", () => {
|
test("keeps masthead controls keyboard-focusable with a paper-coloured focus outline", () => {
|
||||||
render(
|
render(
|
||||||
<PortalShell>
|
<PortalShell
|
||||||
|
brandHref="/redaktion/alben"
|
||||||
|
sectionLabel="Redaktionsarchiv"
|
||||||
|
nav={[{ href: "/redaktion/alben", label: "Alben" }]}
|
||||||
|
>
|
||||||
<p>Archiv</p>
|
<p>Archiv</p>
|
||||||
</PortalShell>,
|
</PortalShell>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByRole("link", { name: /zur albenübersicht/i }).tagName).toBe("A");
|
// 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");
|
expect(screen.getByRole("link", { name: "Alben" }).tagName).toBe("A");
|
||||||
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");
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
import { authClient } from "@/modules/auth/client";
|
||||||
|
|
||||||
|
// Renders into the portal masthead. Better Auth's signOut clears the session
|
||||||
|
// cookie server-side; we then hard-navigate to the login page so no stale
|
||||||
|
// session remains in the client router cache.
|
||||||
|
export function LogoutButton() {
|
||||||
|
const [pending, setPending] = useState(false);
|
||||||
|
|
||||||
|
async function signOut() {
|
||||||
|
setPending(true);
|
||||||
|
try {
|
||||||
|
await authClient.signOut();
|
||||||
|
} finally {
|
||||||
|
window.location.assign("/anmelden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button className="portal-signout" disabled={pending} onClick={signOut} type="button">
|
||||||
|
{pending ? "…" : "Abmelden"}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,24 +3,48 @@ import type { ReactNode } from "react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
import { BrandLogo } from "@/components/brand/logo";
|
import { BrandLogo } from "@/components/brand/logo";
|
||||||
|
import { LogoutButton } from "@/components/layout/logout-button";
|
||||||
|
|
||||||
export function PortalShell({ children }: Readonly<{ children: ReactNode }>) {
|
export type NavItem = { href: string; label: string };
|
||||||
|
|
||||||
|
type PortalShellProps = {
|
||||||
|
brandHref: string;
|
||||||
|
sectionLabel: string;
|
||||||
|
nav: NavItem[];
|
||||||
|
// Editorial pages are wrapped in `.editorial-work-surface` (width + padding),
|
||||||
|
// so their content uses `.editorial-section` (max-width: 100%). Admin pages
|
||||||
|
// bring their own `.content-section` container (width + padding), so the
|
||||||
|
// shell must not add a second width wrapper — pass an empty string here.
|
||||||
|
mainClassName?: string;
|
||||||
|
children: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function PortalShell({
|
||||||
|
brandHref,
|
||||||
|
sectionLabel,
|
||||||
|
nav,
|
||||||
|
mainClassName = "editorial-work-surface",
|
||||||
|
children,
|
||||||
|
}: Readonly<PortalShellProps>) {
|
||||||
return (
|
return (
|
||||||
<div className="editorial-shell">
|
<div className="editorial-shell">
|
||||||
<header className="portal-masthead">
|
<header className="portal-masthead">
|
||||||
<Link aria-label="Zur Albenübersicht" className="portal-brand" href="/redaktion/alben">
|
<Link aria-label={sectionLabel} className="portal-brand" href={brandHref}>
|
||||||
<BrandLogo variant="white" />
|
<BrandLogo variant="white" />
|
||||||
</Link>
|
</Link>
|
||||||
<div className="portal-masthead-meta">
|
<div className="portal-masthead-meta">
|
||||||
<span>Redaktionsarchiv</span>
|
<span>{sectionLabel}</span>
|
||||||
<nav aria-label="Redaktion">
|
<nav aria-label={sectionLabel}>
|
||||||
<Link href="/redaktion/alben">Alben</Link>
|
{nav.map((item) => (
|
||||||
<Link href="/redaktion/nutzungen">Nutzungen</Link>
|
<Link key={item.href} href={item.href}>
|
||||||
<Link href="/redaktion/profil">Profil</Link>
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
|
<LogoutButton />
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main className="editorial-work-surface">{children}</main>
|
<main className={mainClassName}>{children}</main>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user