feat: redesign portal UI with Sakani UI and add release notes

Replace the hand-rolled Tailwind/shadcn look with Sakani UI across the
editorial area, the admin area and all signed-out pages.

- AppShell (Sakani Sidebar + TopBar) for /redaktion and /admin, with a
  mobile drawer, theme toggle, sign-out, legal links and a "Was ist neu"
  button; PublicShell for login, registration, password, 2FA and errors.
- Shared primitives (Button, Card, Input, PageHeader) now render Sakani;
  components/ui/sakani.tsx is the client boundary for Server Components
  (Sakani ships no "use client") and adds FormSelect (native form value)
  and DataTable (element cells from the server).
- Legacy CSS variables map onto Sakani tokens; globals.css shrinks from
  ~2200 to ~700 lines. Geist replaces Inter. recharts/lucide-react dropped
  (charts via Sakani BarChart).
- Release notes popup per area, shown once per version (localStorage) and
  reopenable from the sidebar; native <dialog> for focus trapping.
- Fixes found while testing: TOTP field reused the typed password in
  clear text, modal dialogs sat top-left, invisible unchecked checkboxes
  in dark mode.
- Parallel run: compose.parallel.yaml, AUTO_RULE_SYNC_DISABLED switch and
  docs/operations.md §8 (start, rollback, cutover).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude Opus 5.5 committed 2026-11-30 18:24:05 +01:00
1 parent 453bece72c
commit 9e938e4d07
79 files changed
+2266 -4316

No files matched your search

-30
View File
@@ -1,30 +0,0 @@
"use client";
import { useActionState } from "react";
import type { AlbumActionResult } from "@/app/admin/redaktionen/[id]/alben/actions";
// Client wrapper so the grant/revoke result (a returned object, not a thrown
// error) surfaces as inline German text via useActionState. The page picks the
// bound server action (grant or revoke) based on `isGranted`.
export function AlbumGrantForm({
action,
isGranted,
albumId,
}: Readonly<{
action: (state: AlbumActionResult, formData: FormData) => Promise<AlbumActionResult>;
isGranted: boolean;
albumId: string;
}>) {
const [state, formAction, pending] = useActionState(action, { ok: true, message: "" });
return (
<form action={formAction}>
<input name="immichAlbumId" type="hidden" value={albumId} />
<button type="submit" disabled={pending}>
{pending ? "…" : isGranted ? "Zuweisung aufheben" : "Album zuweisen"}
</button>
{state.ok ? null : <p role="alert">{state.message}</p>}
</form>
);
}
-38
View File
@@ -1,38 +0,0 @@
"use client";
import { useActionState } from "react";
import type { ApproveActionResult } from "@/app/admin/redaktionen/[id]/actions";
// Client wrapper so the approve result (a returned object, not a thrown
// error) surfaces as inline German text via useActionState. `canApprove`
// mirrors the server-side gate (email verified + active album grant).
export function ApproveForm({
action,
canApprove,
}: Readonly<{
action: (state: ApproveActionResult, formData: FormData) => Promise<ApproveActionResult>;
canApprove: boolean;
}>) {
const [state, formAction, pending] = useActionState(action, { ok: true, message: "" });
return (
<form action={formAction} className="account-form">
<label>
Individueller Nettopreis (EUR)
<input
inputMode="decimal"
min="0.01"
name="priceEuros"
required
step="0.01"
type="number"
/>
</label>
<button type="submit" disabled={!canApprove || pending}>
{pending ? "…" : "Redaktion freigeben"}
</button>
{state.ok ? null : <p role="alert">{state.message}</p>}
</form>
);
}
-52
View File
@@ -1,52 +0,0 @@
// @vitest-environment jsdom
import { readFileSync } from "node:fs";
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";
test("lets CSS constrain both supplied logo variants without oversized intrinsic attributes", () => {
render(<BrandLogo />);
const logos = screen.getAllByAltText("Leon Tonhäuser Sportfotografie");
expect(logos).toHaveLength(2);
expect(logos[0].getAttribute("width")).toBeNull();
expect(logos[0].getAttribute("height")).toBeNull();
expect(logos[0].className).toContain("brand-logo-light");
expect(logos[1].getAttribute("width")).toBeNull();
expect(logos[1].getAttribute("height")).toBeNull();
expect(logos[1].className).toContain("brand-logo-dark");
});
test("keeps masthead controls keyboard-focusable with a paper-coloured focus outline", () => {
render(
<PortalShell
brandHref="/redaktion/alben"
sectionLabel="Redaktionsarchiv"
nav={[{ href: "/redaktion/alben", label: "Alben" }]}
>
<p>Archiv</p>
</PortalShell>,
);
// 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)");
});
-18
View File
@@ -1,18 +0,0 @@
/* eslint-disable @next/next/no-img-element */
export function BrandLogo() {
return (
<>
<img
alt="Leon Tonhäuser Sportfotografie"
className="brand-logo brand-logo-light"
src="/brand/logo-black.png"
/>
<img
alt="Leon Tonhäuser Sportfotografie"
className="brand-logo brand-logo-dark"
src="/brand/logo-white.png"
/>
</>
);
}
+9 -7
View File
@@ -1,6 +1,8 @@
"use client";
import { useRef, useState, type FormEvent } from "react";
import { Alert, Button } from "@sakaniui/react";
import { IconDownload } from "@sakaniui/react/icons";
import { formatBerlinDate } from "@/modules/downloads/format";
import type { DownloadDialogUsage } from "@/modules/downloads/stream";
@@ -115,9 +117,9 @@ export function UsageDialog({
return (
<>
<button className="download-trigger" onClick={openDialog} type="button">
<Button leftIcon={<IconDownload size={16} />} onClick={openDialog} size="sm" type="button" variant="secondary">
Original laden
</button>
</Button>
<dialog
aria-labelledby={`usage-dialog-title-${assetId}`}
className="usage-dialog"
@@ -196,19 +198,19 @@ export function UsageDialog({
/>
</label>
{error ? <p role="alert">{error}</p> : null}
{error ? <Alert color="danger" description={error} /> : null}
<div className="usage-dialog-actions">
<button disabled={pending} onClick={closeDialog} type="button">
<Button disabled={pending} onClick={closeDialog} type="button" variant="ghost">
Abbrechen
</button>
<button className="download-confirm" disabled={pending} type="submit">
</Button>
<Button disabled={pending} type="submit">
{pending
? "Download wird vorbereitet …"
: error
? "Download erneut anfordern"
: "Download anfordern"}
</button>
</Button>
</div>
</form>
</dialog>
+76
View File
@@ -0,0 +1,76 @@
// @vitest-environment jsdom
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, expect, test, vi } from "vitest";
const { push } = vi.hoisted(() => ({ push: vi.fn() }));
vi.mock("next/navigation", () => ({
usePathname: () => "/redaktion/alben/abc",
useRouter: () => ({ push }),
}));
vi.mock("next-themes", () => ({ useTheme: () => ({ resolvedTheme: "light", setTheme: vi.fn() }) }));
vi.mock("@/modules/auth/client", () => ({ authClient: { signOut: vi.fn() } }));
import { AppShell } from "./app-shell";
import { RELEASE } from "./release-notes";
const legal = {
imprint: "https://example.com/impressum",
privacy: "https://example.com/datenschutz",
terms: "https://example.com/agb",
};
beforeEach(() => {
// The release-notes popup is not under test here unless a test clears this.
localStorage.setItem("release-notes-seen:redaktion", RELEASE.version);
});
afterEach(() => {
cleanup();
localStorage.clear();
push.mockClear();
});
test("marks the active section and routes sidebar links client-side", () => {
render(<AppShell area="redaktion" legal={legal}>Inhalt</AppShell>);
const albums = screen.getByRole("link", { name: "Alben" });
expect(albums.getAttribute("aria-current")).toBe("page");
const lightbox = screen.getByRole("link", { name: "Merkzettel" });
expect(fireEvent.click(lightbox)).toBe(false); // default (full reload) prevented
expect(push).toHaveBeenCalledWith("/redaktion/leuchtkasten");
push.mockClear();
fireEvent.click(lightbox, { metaKey: true }); // new-tab clicks stay native
expect(push).not.toHaveBeenCalled();
});
test("legal links sit in the sidebar and open natively in a new tab", () => {
render(<AppShell area="redaktion" legal={legal}>Inhalt</AppShell>);
const imprint = screen.getByRole("link", { name: "Impressum" });
expect(imprint.getAttribute("href")).toBe(legal.imprint);
expect(imprint.getAttribute("target")).toBe("_blank");
expect(fireEvent.click(imprint)).toBe(true); // not intercepted
expect(push).not.toHaveBeenCalled();
expect(screen.getByRole("link", { name: "Datenschutz" })).toBeTruthy();
expect(screen.getByRole("link", { name: "Nutzungsbedingungen" })).toBeTruthy();
});
test("release notes pop up once per version and reopen from the sidebar", async () => {
localStorage.clear();
const { unmount } = render(<AppShell area="admin" legal={legal}>Inhalt</AppShell>);
expect(await screen.findByRole("dialog", { name: "Was ist neu?" })).toBeTruthy();
fireEvent.click(screen.getByRole("button", { name: "Verstanden" }));
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
expect(localStorage.getItem("release-notes-seen:admin")).toBe(RELEASE.version);
unmount();
render(<AppShell area="admin" legal={legal}>Inhalt</AppShell>);
expect(screen.queryByRole("dialog")).toBeNull(); // seen: stays closed
fireEvent.click(screen.getByRole("button", { name: new RegExp(`Was ist neu · v${RELEASE.version}`) }));
expect(await screen.findByRole("dialog", { name: "Was ist neu?" })).toBeTruthy();
});
+191
View File
@@ -0,0 +1,191 @@
"use client";
/* eslint-disable @next/next/no-img-element */
import { useEffect, useState, type MouseEvent, type ReactNode } from "react";
import { usePathname, useRouter } from "next/navigation";
import { useTheme } from "next-themes";
import { Button, IconButton, Sidebar, SidebarHeader, SidebarItem, TopBar } from "@sakaniui/react";
import {
IconBookmark,
IconChecklist,
IconLayoutDashboard,
IconLibraryPhoto,
IconLogout,
IconMenu2,
IconReceipt,
IconSparkles,
IconSpeakerphone,
IconSunMoon,
IconUserCircle,
IconUsers,
IconX,
} from "@sakaniui/react/icons";
import { authClient } from "@/modules/auth/client";
import { RELEASE, ReleaseNotesDialog } from "./release-notes";
export type LegalUrls = { imprint: string; privacy: string; terms: string };
// Nav lives here, not in the (server) layouts: icon components cannot cross
// the server→client boundary as props.
const AREAS = {
redaktion: {
label: "Redaktionsarchiv",
nav: [
{ href: "/redaktion/alben", label: "Alben", icon: IconLibraryPhoto },
{ href: "/redaktion/leuchtkasten", label: "Merkzettel", icon: IconBookmark },
{ href: "/redaktion/nutzungen", label: "Nutzungen", icon: IconReceipt },
{ href: "/redaktion/profil", label: "Profil", icon: IconUserCircle },
],
},
admin: {
label: "Administration",
nav: [
{ href: "/admin", label: "Dashboard", icon: IconLayoutDashboard },
{ href: "/admin/redaktionen", label: "Redaktionen", icon: IconUsers },
{ href: "/admin/alben", label: "Alben", icon: IconLibraryPhoto },
{ href: "/admin/hinweise", label: "Hinweise", icon: IconSpeakerphone },
{ href: "/admin/abrechnungen", label: "Abrechnungen", icon: IconReceipt },
{ href: "/admin/audit", label: "Audit", icon: IconChecklist },
],
},
};
export function AppShell({
area,
legal,
children,
}: Readonly<{ area: keyof typeof AREAS; legal: LegalUrls; children: ReactNode }>) {
const { label: SECTION_LABEL, nav: NAV } = AREAS[area];
const pathname = usePathname();
const router = useRouter();
const { resolvedTheme, setTheme } = useTheme();
const [menuOpen, setMenuOpen] = useState(false);
const [signingOut, setSigningOut] = useState(false);
const [notesOpen, setNotesOpen] = useState(false);
const active = NAV.filter(({ href }) => pathname === href || pathname.startsWith(`${href}/`))
.sort((a, b) => b.href.length - a.href.length)[0];
useEffect(() => {
if (!menuOpen) return;
const close = (event: KeyboardEvent) => event.key === "Escape" && setMenuOpen(false);
document.addEventListener("keydown", close);
return () => document.removeEventListener("keydown", close);
}, [menuOpen]);
// ponytail: SidebarItem renders a plain <a href>, which would reload the
// whole page. Catch plain left-clicks and route client-side instead; no
// prefetch. Swap for a Link-aware item if Sakani ever accepts one.
function navigate(event: MouseEvent) {
const link = (event.target as HTMLElement).closest("a");
const href = link?.getAttribute("href");
// Only internal nav links; legal links open in a new tab as usual.
if (!link || link.target || !href?.startsWith("/")) return;
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
event.preventDefault();
setMenuOpen(false);
router.push(href);
}
async function signOut() {
setSigningOut(true);
try {
await authClient.signOut();
} finally {
window.location.replace("/anmelden");
}
}
return (
<div data-app-shell className="flex min-h-dvh bg-[var(--color-bg-canvas)] text-[var(--color-fg-default)]">
<ReleaseNotesDialog area={area} open={notesOpen} onOpenChange={setNotesOpen} />
{menuOpen ? (
<div aria-hidden="true" className="fixed inset-0 z-40 bg-black/40 md:hidden" onClick={() => setMenuOpen(false)} />
) : null}
<div
id="editorial-sidebar"
onClick={navigate}
className={`${menuOpen ? "max-md:flex" : "max-md:hidden"} fixed inset-y-0 left-0 z-50 flex border-r bg-[var(--color-bg-canvas)] border-[var(--color-border-subtle)] md:sticky md:top-0 md:h-dvh`}
>
{/* Sakani drops aria-label on Sidebar; its <nav> stays the main nav landmark. */}
<Sidebar>
<SidebarHeader
title={SECTION_LABEL}
subtitle="Leon Tonhäuser Sportfotografie"
logo={
// Decorative: the header title next to it names the portal.
// brand-logo-light/-dark only toggle display via the .dark class.
<>
<img alt="" className="brand-logo-light" height={32} src="/brand/logo-black.png" width={32} />
<img alt="" className="brand-logo-dark" height={32} src="/brand/logo-white.png" width={32} />
</>
}
/>
<div className="mt-4 flex flex-col gap-1">
{NAV.map((item) => (
<SidebarItem
key={item.href}
href={item.href}
label={item.label}
icon={item.icon}
active={item.href === active?.href}
/>
))}
</div>
<div className="mt-auto flex flex-col items-start gap-1 border-t border-[var(--color-border-subtle)] pt-3 pb-3">
<Button variant="ghost" size="sm" leftIcon={<IconSparkles size={16} />} onClick={() => setNotesOpen(true)}>
Was ist neu · v{RELEASE.version}
</Button>
<nav aria-label="Rechtliches" className="flex flex-wrap gap-x-3 gap-y-1 px-3 py-1 text-xs text-[var(--color-fg-muted)]">
<a className="hover:text-[var(--color-fg-default)] hover:underline" href={legal.imprint} rel="noreferrer noopener" target="_blank">Impressum</a>
<a className="hover:text-[var(--color-fg-default)] hover:underline" href={legal.privacy} rel="noreferrer noopener" target="_blank">Datenschutz</a>
<a className="hover:text-[var(--color-fg-default)] hover:underline" href={legal.terms} rel="noreferrer noopener" target="_blank">Nutzungsbedingungen</a>
</nav>
<Button variant="ghost" size="sm" leftIcon={<IconLogout size={16} />} loading={signingOut} onClick={signOut}>
Abmelden
</Button>
</div>
</Sidebar>
</div>
<div className="flex min-w-0 flex-1 flex-col">
<div className="sticky top-0 z-30 border-b border-[var(--color-border-subtle)] bg-[var(--color-bg-canvas)]">
<TopBar
type="minimal"
density="sm"
showToggle={false}
showActions={false}
left={
<div className="flex items-center gap-2">
<span className="md:hidden">
<IconButton
variant="ghost"
size="sm"
icon={menuOpen ? IconX : IconMenu2}
aria-label={menuOpen ? "Menü schließen" : "Menü öffnen"}
aria-expanded={menuOpen}
aria-controls="editorial-sidebar"
onClick={() => setMenuOpen((open) => !open)}
/>
</span>
<span className="text-sm font-medium">{active?.label ?? SECTION_LABEL}</span>
</div>
}
rightSlot={
<IconButton
variant="ghost"
size="sm"
icon={IconSunMoon}
aria-label="Hell/Dunkel umschalten"
onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
/>
}
/>
</div>
<main className="mx-auto w-full max-w-7xl flex-1 px-4 py-8 sm:px-8 lg:py-12">{children}</main>
</div>
</div>
);
}
-33
View File
@@ -1,33 +0,0 @@
"use client";
import { useState } from "react";
import { authClient } from "@/modules/auth/client";
import { Button } from "@/components/ui/button";
// Renders into the portal masthead. Better Auth's signOut clears the session
// cookie server-side; a hard replacement clears any stale router cache.
export function LogoutButton() {
const [pending, setPending] = useState(false);
async function signOut() {
setPending(true);
try {
await authClient.signOut();
} finally {
window.location.replace("/anmelden");
}
}
return (
<Button
variant="outline"
size="sm"
disabled={pending}
onClick={signOut}
type="button"
>
{pending ? "…" : "Abmelden"}
</Button>
);
}
@@ -1,94 +0,0 @@
// @vitest-environment jsdom
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, beforeEach, expect, test, vi } from "vitest";
const { usePathname } = vi.hoisted(() => ({
usePathname: vi.fn(),
}));
vi.mock("next/navigation", () => ({ usePathname }));
import { MobilePortalMenu } from "./mobile-portal-menu";
const nav = [
{ href: "/admin", label: "Dashboard" },
{ href: "/admin/redaktionen", label: "Redaktionen" },
{ href: "/admin/abrechnungen", label: "Abrechnungen" },
{ href: "/admin/audit", label: "Audit" },
];
beforeEach(() => usePathname.mockReturnValue("/admin/redaktionen/abc"));
afterEach(cleanup);
test("opens every mobile portal action and marks the most specific active route", () => {
render(<MobilePortalMenu nav={nav} sectionLabel="Administration" />);
const trigger = screen.getByRole("button", { name: /menü öffnen/i });
expect(trigger.getAttribute("aria-expanded")).toBe("false");
expect(screen.queryByRole("navigation", { name: /mobile navigation/i })).toBeNull();
fireEvent.click(trigger);
expect(trigger.getAttribute("aria-expanded")).toBe("true");
const inactiveLink = screen.getByRole("link", { name: "Dashboard" });
const activeLink = screen.getByRole("link", { name: "Redaktionen" });
expect(inactiveLink).toBeTruthy();
expect(activeLink.getAttribute("aria-current")).toBe("page");
expect(activeLink.getAttribute("class")).toContain("mobile-portal-menu-active");
expect(inactiveLink.getAttribute("class")).not.toContain("mobile-portal-menu-active");
expect(screen.getByRole("link", { name: "Abrechnungen" })).toBeTruthy();
expect(screen.getByRole("link", { name: "Audit" })).toBeTruthy();
expect(screen.getByRole("button", { name: /design umschalten/i })).toBeTruthy();
expect(screen.getByRole("button", { name: /abmelden/i })).toBeTruthy();
});
test("keeps nested theme and logout buttons at least 44px tall", () => {
render(<MobilePortalMenu nav={nav} sectionLabel="Administration" />);
fireEvent.click(screen.getByRole("button", { name: /menü öffnen/i }));
const themeToggle = screen.getByRole("button", { name: /design umschalten/i });
const logoutButton = screen.getByRole("button", { name: /abmelden/i });
expect(themeToggle.parentElement?.getAttribute("class")).toContain("[&>button]:min-h-11");
expect(themeToggle.parentElement?.getAttribute("class")).toContain("[&>button]:min-w-11");
expect(logoutButton.parentElement?.getAttribute("class")).toContain("[&>button]:min-h-11");
});
test("caps the open panel to the dynamic viewport and keeps every action scrollable", () => {
render(<MobilePortalMenu nav={nav} sectionLabel="Administration" />);
fireEvent.click(screen.getByRole("button", { name: /menü öffnen/i }));
const panel = screen.getByRole("navigation", { name: /mobile navigation/i }).parentElement;
expect(panel?.getAttribute("class")).toContain("max-h-[calc(100dvh-5.5rem)]");
expect(panel?.getAttribute("class")).toContain("overflow-y-auto");
expect(panel?.getAttribute("class")).toContain("overscroll-contain");
});
test("closes after navigation, Escape and an outside pointer interaction", () => {
render(
<div>
<MobilePortalMenu nav={nav} sectionLabel="Administration" />
<button type="button">Außerhalb</button>
</div>,
);
const trigger = screen.getByRole("button", { name: /menü öffnen/i });
fireEvent.click(trigger);
const auditLink = screen.getByRole("link", { name: "Audit" });
auditLink.addEventListener("click", (event) => event.preventDefault(), { once: true });
fireEvent.click(auditLink);
expect(trigger.getAttribute("aria-expanded")).toBe("false");
fireEvent.click(trigger);
fireEvent.keyDown(document, { key: "Escape" });
expect(trigger.getAttribute("aria-expanded")).toBe("false");
expect(document.activeElement).toBe(trigger);
fireEvent.click(trigger);
fireEvent.pointerDown(screen.getByRole("button", { name: "Außerhalb" }));
expect(trigger.getAttribute("aria-expanded")).toBe("false");
});
@@ -1,104 +0,0 @@
"use client";
import { useEffect, useMemo, useRef, useState } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { Menu, X } from "lucide-react";
import type { NavItem } from "@/components/layout/portal-shell";
import { LogoutButton } from "@/components/layout/logout-button";
import { ThemeToggle } from "@/components/theme-toggle";
type MobilePortalMenuProps = {
nav: NavItem[];
sectionLabel: string;
};
export function MobilePortalMenu({ nav, sectionLabel }: Readonly<MobilePortalMenuProps>) {
const pathname = usePathname();
const [open, setOpen] = useState(false);
const containerRef = useRef<HTMLDivElement>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
const menuId = "mobile-portal-menu";
const activeHref = useMemo(
() => nav
.filter(({ href }) => pathname === href || pathname.startsWith(`${href}/`))
.sort((left, right) => right.href.length - left.href.length)[0]?.href,
[nav, pathname],
);
useEffect(() => {
if (!open) return;
function closeOnOutsidePointer(event: PointerEvent) {
if (!containerRef.current?.contains(event.target as Node)) setOpen(false);
}
function closeOnEscape(event: KeyboardEvent) {
if (event.key !== "Escape") return;
setOpen(false);
triggerRef.current?.focus();
}
document.addEventListener("pointerdown", closeOnOutsidePointer);
document.addEventListener("keydown", closeOnEscape);
return () => {
document.removeEventListener("pointerdown", closeOnOutsidePointer);
document.removeEventListener("keydown", closeOnEscape);
};
}, [open]);
return (
<div ref={containerRef} className="relative sm:hidden">
<button
ref={triggerRef}
type="button"
aria-controls={menuId}
aria-expanded={open}
aria-label={open ? "Menü schließen" : "Menü öffnen"}
className="inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-background px-3 text-sm font-semibold"
onClick={() => setOpen((current) => !current)}
>
{open ? <X aria-hidden="true" className="size-5" /> : <Menu aria-hidden="true" className="size-5" />}
Menü
</button>
{open ? (
<div
id={menuId}
className="mobile-portal-menu-panel absolute right-0 top-[calc(100%+0.75rem)] z-50 max-h-[calc(100dvh-5.5rem)] w-[min(22rem,calc(100vw-2rem))] overflow-y-auto overscroll-contain rounded-xl border border-border bg-background p-2 shadow-xl"
>
<p className="px-3 py-2 text-xs font-bold uppercase tracking-widest text-[var(--muted)]">
{sectionLabel}
</p>
<nav aria-label="Mobile Navigation" className="grid gap-1">
{nav.map((item) => {
const active = item.href === activeHref;
return (
<Link
key={item.href}
href={item.href}
aria-current={active ? "page" : undefined}
className={active
? "mobile-portal-menu-active flex min-h-11 items-center rounded-lg px-3 font-semibold"
: "flex min-h-11 items-center rounded-lg px-3 font-medium hover:bg-[var(--soft)]"}
onClick={() => setOpen(false)}
>
{item.label}
</Link>
);
})}
</nav>
<div className="mt-2 flex min-h-11 items-center justify-between border-t border-border px-3 pt-2 [&>button]:min-h-11 [&>button]:min-w-11">
<span className="text-sm text-[var(--muted)]">Darstellung</span>
<ThemeToggle />
</div>
<div className="mt-2 border-t border-border px-3 pt-2 [&>button]:min-h-11">
<LogoutButton />
</div>
</div>
) : null}
</div>
);
}
-62
View File
@@ -1,62 +0,0 @@
import type { ReactNode } from "react";
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 };
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 (
<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-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>
<div className="flex items-center gap-6 text-sm font-medium">
<span className="hidden md:inline-block text-muted-foreground uppercase tracking-widest text-xs font-bold">{sectionLabel}</span>
<nav aria-label={sectionLabel} className="hidden sm:flex items-center gap-6">
{nav.map((item) => (
<Link
key={item.href}
href={item.href}
className="transition-colors hover:text-primary-500 text-foreground"
>
{item.label}
</Link>
))}
</nav>
<div className="hidden items-center gap-4 sm:flex">
<ThemeToggle />
<LogoutButton />
</div>
<MobilePortalMenu nav={nav} sectionLabel={sectionLabel} />
</div>
</div>
</header>
<main className="flex-1 w-full max-w-7xl mx-auto px-6 py-12 lg:px-12 lg:py-16">{children}</main>
</div>
);
}
+51
View File
@@ -0,0 +1,51 @@
/* eslint-disable @next/next/no-img-element */
import type { ReactNode } from "react";
import Link from "next/link";
import { Card } from "@/components/ui/sakani";
// Frame for the signed-out pages (landing, login, registration, password,
// 2FA, error): brand bar on top, one centred Sakani card with the content.
export function PublicShell({
kicker,
title,
titleId,
lede,
wide = false,
children,
}: Readonly<{
kicker: string;
title: string;
titleId: string;
lede?: ReactNode;
wide?: boolean;
children?: ReactNode;
}>) {
return (
<main className="flex min-h-dvh flex-col bg-[var(--color-bg-canvas)] text-[var(--color-fg-default)]">
<header className="flex items-center justify-between gap-4 border-b border-[var(--color-border-subtle)] px-4 py-3 sm:px-8">
<Link className="flex items-center gap-3 rounded-[var(--radius-md)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-border-focus)]" href="/">
<img alt="" className="brand-logo-light" height={32} src="/brand/logo-black.png" width={32} />
<img alt="" className="brand-logo-dark" height={32} src="/brand/logo-white.png" width={32} />
<span className="text-sm font-semibold">Leon Tonhäuser</span>
</Link>
<span className="text-xs font-medium uppercase tracking-wider text-[var(--color-fg-muted)]">Redaktionsportal</span>
</header>
<div className="flex flex-1 items-start justify-center px-4 py-10 sm:py-16">
<section aria-labelledby={titleId} className={`w-full ${wide ? "max-w-3xl" : "max-w-md"}`}>
<Card>
{/* Sakani's card body mutes text and adds no gap; this wrapper restores both. */}
<div className="flex flex-col gap-6 text-base text-[var(--color-fg-default)]">
<header className="flex flex-col gap-2">
<p className="text-xs font-medium uppercase tracking-wider text-[var(--color-fg-muted)]">{kicker}</p>
<h1 id={titleId} className="text-2xl font-semibold tracking-tight">{title}</h1>
{lede ? <p className="text-[var(--color-fg-muted)]">{lede}</p> : null}
</header>
{children}
</div>
</Card>
</section>
</div>
</main>
);
}
+106
View File
@@ -0,0 +1,106 @@
"use client";
import { useEffect, useRef } from "react";
import { Button } from "@sakaniui/react";
import { IconCheck } from "@sakaniui/react/icons";
// Bump RELEASE.version for the next release and replace the notes: every user
// then sees the popup once more. ponytail: only the latest release is kept;
// add a history list when users ask for older notes.
export const RELEASE = {
version: "2.0",
title: "Neues Design",
notes: {
redaktion: [
"Neues, ruhigeres Design – hell oder dunkel, umschaltbar oben rechts.",
"Navigation links in einer Seitenleiste, auf dem Handy über das Menü-Symbol.",
"Suche und Filter nach Format und Jahr übersichtlich in einem Feld.",
"Nutzungen und Abrechnungen zeigen ihren Status farbig (Offen, Abgerechnet …).",
"Der Download-Dialog erscheint jetzt mittig im Bild.",
"Impressum, Datenschutz und Nutzungsbedingungen finden Sie unten links.",
],
admin: [
"Neues Design mit Seitenleiste für alle Admin-Bereiche, hell oder dunkel.",
"Dashboard mit Umsatz des Monats und Download-Diagramm der letzten 30 Tage.",
"Redaktionen als Karten mit Status, Preis und offenem Betrag.",
"Albumrechte mit Vorschaubild; zugewiesene Alben sind grün markiert.",
"Abrechnung als Tabelle mit Auswahl, Status und Summe auf einen Blick.",
"Hinweise, Audit-Protokoll und Anmeldung im neuen Layout.",
],
},
} as const;
export type ReleaseArea = keyof typeof RELEASE.notes;
const seenKey = (area: ReleaseArea) => `release-notes-seen:${area}`;
// Per browser, not per account: a courtesy popup, not a record of consent.
function readSeen(area: ReleaseArea): string | null {
try {
return window.localStorage.getItem(seenKey(area));
} catch {
return RELEASE.version; // storage blocked: don't nag on every page load
}
}
function markSeen(area: ReleaseArea) {
try {
window.localStorage.setItem(seenKey(area), RELEASE.version);
} catch {
/* storage blocked — nothing to persist */
}
}
// Native <dialog>.showModal() instead of Sakani's Modal: it traps focus, makes
// the page inert and handles Escape; Sakani's Modal left focus on the page.
export function ReleaseNotesDialog({
area,
open,
onOpenChange,
}: Readonly<{ area: ReleaseArea; open: boolean; onOpenChange: (open: boolean) => void }>) {
const ref = useRef<HTMLDialogElement>(null);
// Open once per version, after hydration (localStorage is client-only).
useEffect(() => {
if (readSeen(area) !== RELEASE.version) onOpenChange(true);
}, [area, onOpenChange]);
useEffect(() => {
const dialog = ref.current;
if (!dialog) return;
if (open && !dialog.open) dialog.showModal();
if (!open && dialog.open) dialog.close();
}, [open]);
// Runs for the button, Escape and dialog.close() alike.
function handleClose() {
markSeen(area);
onOpenChange(false);
}
return (
<dialog ref={ref} aria-labelledby="release-notes-title" className="usage-dialog max-w-lg" onClose={handleClose}>
<div className="flex flex-col gap-5 p-6">
<header className="flex flex-col gap-1">
<p className="text-xs font-medium uppercase tracking-wider text-[var(--color-fg-muted)]">
Version {RELEASE.version} – {RELEASE.title}
</p>
<h2 id="release-notes-title" className="text-xl font-semibold">Was ist neu?</h2>
</header>
<ul className="flex flex-col gap-3 text-sm">
{RELEASE.notes[area].map((note) => (
<li key={note} className="flex gap-3">
<IconCheck aria-hidden="true" className="mt-0.5 shrink-0 text-[var(--color-success-fg)]" size={16} />
<span>{note}</span>
</li>
))}
</ul>
<div className="flex justify-end">
<Button autoFocus onClick={() => ref.current?.close()} type="button">
Verstanden
</Button>
</div>
</div>
</dialog>
);
}
-23
View File
@@ -1,23 +0,0 @@
"use client"
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
import { Button } from "@/components/ui/button"
export function ThemeToggle() {
const { resolvedTheme, setTheme } = useTheme()
return (
<Button
variant="ghost"
size="icon"
onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
title="Design umschalten"
>
<Sun className="h-[1.2rem] w-[1.2rem] transition-all dark:hidden" />
<Moon className="hidden h-[1.2rem] w-[1.2rem] transition-all dark:block" />
<span className="sr-only">Design umschalten</span>
</Button>
)
}
+51 -39
View File
@@ -1,46 +1,58 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cn } from "@/lib/utils"
"use client";
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
asChild?: boolean
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link"
size?: "default" | "sm" | "lg" | "icon"
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { Button as SakaniButton } from "@sakaniui/react";
import { cn } from "@/lib/utils";
// Keeps the old shadcn-style API so call sites stay untouched; renders Sakani.
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
asChild?: boolean;
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
size?: "default" | "sm" | "lg" | "icon";
loading?: boolean;
leftIcon?: React.ReactNode;
rightIcon?: React.ReactNode;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant = "default", size = "default", asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
// Wir nutzen hier klassische Tailwind-Klassen kombiniert mit unseren CSS Variablen
const baseClasses = "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary-500 disabled:pointer-events-none disabled:opacity-50"
const variantClasses = {
default: "bg-primary-600 text-white hover:bg-primary-700 shadow-sm",
destructive: "bg-red-500 text-white hover:bg-red-600 shadow-sm",
outline: "border border-border bg-background hover:bg-accent hover:text-accent-foreground shadow-sm",
secondary: "bg-gray-100 text-gray-900 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-100 dark:hover:bg-gray-700",
ghost: "hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-gray-800 dark:hover:text-gray-100",
link: "text-primary-600 underline-offset-4 hover:underline",
}
const sizeClasses = {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
}
const VARIANT = { default: "primary", destructive: "destructive", outline: "outline", secondary: "secondary", ghost: "ghost", link: "ghost" } as const;
const SIZE = { default: "md", sm: "sm", lg: "lg", icon: "sm" } as const;
// ponytail: Sakani's Button only renders <button>. For `asChild` (a Link that
// looks like a button) we mirror the primary button with tokens on the child.
const LINK_BUTTON =
"inline-flex h-10 items-center justify-center gap-2 rounded-[var(--radius-md)] px-4 text-sm font-medium no-underline transition-colors " +
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-border-focus)]";
const LINK_VARIANT = {
primary: "bg-[var(--color-accent-default)] text-[var(--color-accent-fg)] hover:bg-[var(--color-accent-hover)]",
outline: "border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] text-[var(--color-fg-default)] hover:bg-[var(--color-bg-subtle)]",
};
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant = "default", size = "default", asChild = false, leftIcon, rightIcon, loading, children, ...props }, ref) => {
if (asChild) {
const tone = variant === "outline" || variant === "ghost" || variant === "secondary" ? "outline" : "primary";
return (
<Slot className={cn(LINK_BUTTON, LINK_VARIANT[tone], className)} ref={ref} {...props}>
{children}
</Slot>
);
}
return (
<Comp
className={cn(baseClasses, variantClasses[variant], sizeClasses[size], className)}
<SakaniButton
className={className}
leftIcon={leftIcon}
loading={loading}
ref={ref}
rightIcon={rightIcon}
size={SIZE[size]}
variant={VARIANT[variant]}
{...props}
/>
)
}
)
Button.displayName = "Button"
export { Button }
>
{children}
</SakaniButton>
);
},
);
Button.displayName = "Button";
+24 -63
View File
@@ -1,70 +1,31 @@
import * as React from "react"
import type { HTMLAttributes } from "react";
import { cn } from "@/lib/utils"
import { Card as SakaniCard } from "@/components/ui/sakani";
import { cn } from "@/lib/utils";
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"rounded-xl border border-border bg-card text-card-foreground shadow-sm overflow-hidden",
className
)}
{...props}
/>
)
)
Card.displayName = "Card"
// Old shadcn-style composition API on top of Sakani's Card surface. Sakani's
// Card already pads (20px) and stacks children (gap 16px), so the parts below
// add no padding of their own.
export function Card({ className, children }: HTMLAttributes<HTMLDivElement>) {
return <SakaniCard className={className}>{children}</SakaniCard>;
}
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>
)
)
CardHeader.displayName = "CardHeader"
export function CardHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
return <div className={cn("flex flex-col gap-1", className)} {...props} />;
}
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn("text-2xl font-semibold leading-none tracking-tight", className)}
{...props}
/>
)
)
CardTitle.displayName = "CardTitle"
export function CardTitle({ className, ...props }: HTMLAttributes<HTMLHeadingElement>) {
return <h3 className={cn("text-base font-semibold text-[var(--color-fg-default)]", className)} {...props} />;
}
const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-gray-500 dark:text-gray-400", className)}
{...props}
/>
)
)
CardDescription.displayName = "CardDescription"
export function CardDescription({ className, ...props }: HTMLAttributes<HTMLParagraphElement>) {
return <p className={cn("text-sm text-[var(--color-fg-muted)]", className)} {...props} />;
}
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
)
)
CardContent.displayName = "CardContent"
export function CardContent({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
return <div className={cn("min-w-0", className)} {...props} />;
}
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
{...props}
/>
)
)
CardFooter.displayName = "CardFooter"
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
export function CardFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
return <div className={cn("flex items-center gap-2", className)} {...props} />;
}
+5 -24
View File
@@ -1,25 +1,6 @@
import * as React from "react"
"use client";
import { cn } from "@/lib/utils"
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-border bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:placeholder:text-gray-400",
className
)}
ref={ref}
{...props}
/>
)
}
)
Input.displayName = "Input"
export { Input }
// Old API, Sakani rendering. Prefer importing Input from "@/components/ui/sakani"
// in new code to get label/description/icon props.
export { Input } from "@sakaniui/react";
export type { InputProps } from "@sakaniui/react";
+10 -13
View File
@@ -1,26 +1,23 @@
import React from "react";
import type { ReactNode } from "react";
type PageHeaderProps = {
kicker?: string;
title: string;
description?: string;
description?: ReactNode;
titleId?: string;
children?: React.ReactNode;
children?: ReactNode;
};
// Page title block in Sakani tokens; `children` sit right of the title (actions).
export function PageHeader({ kicker, title, description, titleId, children }: PageHeaderProps) {
return (
<div className="editorial-section">
{kicker && <p className="editorial-kicker text-sm font-semibold text-muted-foreground tracking-widest uppercase mb-2">{kicker}</p>}
<div className="editorial-title-row mb-6">
<h1 id={titleId} className="text-4xl font-bold tracking-tight text-foreground">{title}</h1>
<header className="mb-8 flex flex-col gap-2">
{kicker ? <p className="text-xs font-medium uppercase tracking-wider text-[var(--color-fg-muted)]">{kicker}</p> : null}
<div className="flex flex-wrap items-end justify-between gap-4">
<h1 id={titleId} className="text-3xl font-semibold tracking-tight text-[var(--color-fg-default)]">{title}</h1>
{children}
</div>
{description && (
<p className="text-lg text-muted-foreground max-w-3xl mb-8">
{description}
</p>
)}
</div>
{description ? <p className="max-w-2xl text-base text-[var(--color-fg-muted)]">{description}</p> : null}
</header>
);
}
+24
View File
@@ -0,0 +1,24 @@
// @vitest-environment jsdom
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, expect, test } from "vitest";
import { DataTable, FormSelect } from "./sakani";
afterEach(cleanup);
test("DataTable renders element cells instead of stringifying them", () => {
render(<DataTable columns={[{ key: "name", header: "Name" }]} rows={[{ name: <a href="/x">Kicker</a> }]} />);
expect(screen.getByRole("link", { name: "Kicker" }).getAttribute("href")).toBe("/x");
expect(screen.queryByText("[object Object]")).toBeNull();
});
test("FormSelect submits its value through a named hidden input", () => {
const { container } = render(
<form>
<FormSelect name="format" label="Format" defaultValue="quer" options={[{ label: "Quer", value: "quer" }]} />
</form>,
);
const data = new FormData(container.querySelector("form")!);
expect(data.get("format")).toBe("quer");
});
+55
View File
@@ -0,0 +1,55 @@
"use client";
// @sakaniui/react ships without a "use client" directive and uses hooks and
// context, so Server Components import Sakani through this client boundary.
// Props crossing it must be serialisable: pass icons as elements
// (leftIcon={<IconX />}), never as components (icon={IconX}).
import { useState, type ComponentProps, type ReactNode } from "react";
import { Card as SakaniCard, Select, Table, type SelectOption } from "@sakaniui/react";
export { Alert, Badge, BarChart, Button, Checkbox, EmptyState, Input, Progress, Select, Spinner, StatCard, Textarea } from "@sakaniui/react";
// Sakani's card body mutes its text (fg-muted, 14px) and stacks children with
// no gap — meant for a one-line description. Our cards hold real content.
export function Card({ children, ...props }: ComponentProps<typeof SakaniCard>) {
return (
<SakaniCard {...props}>
<div className="flex flex-col gap-4 text-sm text-[var(--color-fg-default)]">{children}</div>
</SakaniCard>
);
}
// Sakani's Select is a custom combobox without a `name`, so it does not take
// part in a native <form> submit. The hidden input carries the value.
export function FormSelect({
name,
label,
options,
defaultValue = "",
}: Readonly<{ name: string; label: string; options: SelectOption[]; defaultValue?: string }>) {
const [value, setValue] = useState(defaultValue);
return (
<>
<Select label={label} options={options} value={value} onChange={setValue} />
<input type="hidden" name={name} value={value} />
</>
);
}
type Cell = ReactNode;
type DataColumn = { key: string; header: string; align?: "left" | "center" | "right"; width?: string };
// Sakani's Table stringifies cells unless a column has `render`, and render
// functions cannot cross the server→client boundary. Server pages pass rows of
// ready-made cells (strings or elements); this adds the render step.
export function DataTable({
columns,
rows,
}: Readonly<{ columns: DataColumn[]; rows: Array<Record<string, Cell>> }>) {
return (
<Table<Record<string, Cell>>
columns={columns.map((column) => ({ ...column, render: (row) => row[column.key] }))}
rows={rows}
/>
);
}