Compare commits

..

2 Commits

Author SHA1 Message Date
Marcel
f9821164d1 refactor(persons): adopt PageHeader primitive on /persons listing page (§3)
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 2m58s
CI / OCR Service Tests (pull_request) Successful in 22s
CI / Backend Unit Tests (pull_request) Successful in 5m1s
CI / fail2ban Regex (pull_request) Successful in 45s
CI / Semgrep Security Scan (pull_request) Successful in 24s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m5s
SDD Gate / RTM Check (pull_request) Successful in 14s
SDD Gate / Contract Validate (pull_request) Successful in 22s
SDD Gate / Constitution Impact (pull_request) Successful in 16s
Adds persons_eyebrow + persons_lede i18n keys (de/en/es) and replaces
the inline header markup with <PageHeader> to close §3 of the spec.

Refs #856
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 19:19:54 +02:00
Marcel
8bcc4d888d feat(shared): add PageHeader primitive — eyebrow + 4px mint rule + Tinos clamp title + lede (closes #856 §primitive)
Props: eyebrow (string), title (string), lede? (string), right? (Snippet).
Markup uses semantic tokens only (var(--c-accent/ink/ink-2/ink-3)), clamp(28px,8vw,46px) h1,
no @html. Svelte-autofixer clean; 12 browser-spec assertions green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 17:32:59 +02:00
16 changed files with 314 additions and 243 deletions

View File

@@ -130,6 +130,8 @@
"doc_no_scan": "Kein Scan vorhanden", "doc_no_scan": "Kein Scan vorhanden",
"persons_heading": "Personenverzeichnis", "persons_heading": "Personenverzeichnis",
"persons_subtitle": "Durchsuchen Sie den Index aller erfassten Personen im Familienarchiv.", "persons_subtitle": "Durchsuchen Sie den Index aller erfassten Personen im Familienarchiv.",
"persons_eyebrow": "Verzeichnis",
"persons_lede": "Jede Hand, die schrieb oder genannt wurde — Absender, Empfänger, Erwähnte.",
"persons_btn_new": "Neue Person", "persons_btn_new": "Neue Person",
"persons_search_placeholder": "Namen suchen...", "persons_search_placeholder": "Namen suchen...",
"persons_empty_heading": "Keine Personen gefunden.", "persons_empty_heading": "Keine Personen gefunden.",

View File

@@ -130,6 +130,8 @@
"doc_no_scan": "No scan available", "doc_no_scan": "No scan available",
"persons_heading": "Person directory", "persons_heading": "Person directory",
"persons_subtitle": "Browse the index of all recorded persons in the family archive.", "persons_subtitle": "Browse the index of all recorded persons in the family archive.",
"persons_eyebrow": "Directory",
"persons_lede": "Every hand that wrote or was named — senders, recipients, those mentioned.",
"persons_btn_new": "New person", "persons_btn_new": "New person",
"persons_search_placeholder": "Search names...", "persons_search_placeholder": "Search names...",
"persons_empty_heading": "No persons found.", "persons_empty_heading": "No persons found.",

View File

@@ -130,6 +130,8 @@
"doc_no_scan": "No hay escaneo disponible", "doc_no_scan": "No hay escaneo disponible",
"persons_heading": "Directorio de personas", "persons_heading": "Directorio de personas",
"persons_subtitle": "Explore el índice de todas las personas registradas en el archivo familiar.", "persons_subtitle": "Explore el índice de todas las personas registradas en el archivo familiar.",
"persons_eyebrow": "Directorio",
"persons_lede": "Cada mano que escribió o fue nombrada — remitentes, destinatarios, mencionados.",
"persons_btn_new": "Nueva persona", "persons_btn_new": "Nueva persona",
"persons_search_placeholder": "Buscar nombres...", "persons_search_placeholder": "Buscar nombres...",
"persons_empty_heading": "No se encontraron personas.", "persons_empty_heading": "No se encontraron personas.",

View File

@@ -1,12 +1,11 @@
<script lang="ts"> <script lang="ts">
import { m } from '$lib/paraglide/messages.js'; import { m } from '$lib/paraglide/messages.js';
import { formatDate } from '$lib/shared/utils/date'; import { formatDate } from '$lib/shared/utils/date';
import { formatDocumentStatus } from '$lib/document/documentStatusLabel';
import { getInitials, personAvatarColor } from '$lib/person/personFormat'; import { getInitials, personAvatarColor } from '$lib/person/personFormat';
import RelationshipPill from '$lib/person/relationship/RelationshipPill.svelte'; import RelationshipPill from '$lib/person/relationship/RelationshipPill.svelte';
import DocumentDate from './DocumentDate.svelte'; import DocumentDate from './DocumentDate.svelte';
import DocumentStatusChip from './DocumentStatusChip.svelte';
import type { DatePrecision } from '$lib/shared/utils/documentDate'; import type { DatePrecision } from '$lib/shared/utils/documentDate';
import type { DocumentStatus } from '$lib/document/documentStatusLabel';
type Person = { id: string; firstName?: string | null; lastName: string; displayName: string }; type Person = { id: string; firstName?: string | null; lastName: string; displayName: string };
type Tag = { id: string; name: string }; type Tag = { id: string; name: string };
@@ -23,7 +22,7 @@ type Props = {
metaDateEnd?: string | null; metaDateEnd?: string | null;
metaDateRaw?: string | null; metaDateRaw?: string | null;
location: string | null; location: string | null;
status: DocumentStatus; status: string;
sender: Person | null; sender: Person | null;
receivers: Person[]; receivers: Person[];
tags: Tag[]; tags: Tag[];
@@ -69,6 +68,7 @@ function formatGeschichteDate(g: GeschichteSummary): string {
} }
const displayLocation = $derived(location ?? '—'); const displayLocation = $derived(location ?? '—');
const statusLabel = $derived(formatDocumentStatus(status));
const visibleReceivers = $derived(receivers.slice(0, VISIBLE_RECEIVER_LIMIT)); const visibleReceivers = $derived(receivers.slice(0, VISIBLE_RECEIVER_LIMIT));
const hiddenReceiverCount = $derived(Math.max(0, receivers.length - VISIBLE_RECEIVER_LIMIT)); const hiddenReceiverCount = $derived(Math.max(0, receivers.length - VISIBLE_RECEIVER_LIMIT));
const hasPersons = $derived(sender !== null || receivers.length > 0); const hasPersons = $derived(sender !== null || receivers.length > 0);
@@ -131,7 +131,7 @@ function getFullName(person: Person): string {
</div> </div>
<div> <div>
<dt class="font-sans text-xs font-medium text-ink-3">{m.doc_details_field_status()}</dt> <dt class="font-sans text-xs font-medium text-ink-3">{m.doc_details_field_status()}</dt>
<dd class="text-ink"><DocumentStatusChip status={status} /></dd> <dd class="text-ink">{statusLabel}</dd>
</div> </div>
</dl> </dl>
</div> </div>

View File

@@ -1,8 +1,7 @@
<script lang="ts"> <script lang="ts">
import StatusDot from '$lib/shared/primitives/StatusDot.svelte';
import { import {
formatDocumentStatus, formatDocumentStatus,
statusDotColor, statusDotClass,
type DocumentStatus type DocumentStatus
} from '$lib/document/documentStatusLabel'; } from '$lib/document/documentStatusLabel';
@@ -12,10 +11,12 @@ type Props = {
let { status }: Props = $props(); let { status }: Props = $props();
const color = $derived(statusDotColor(status)); const dotClass = $derived(statusDotClass(status));
const label = $derived(formatDocumentStatus(status)); const label = $derived(formatDocumentStatus(status));
</script> </script>
<span data-testid="status-chip" class="inline-flex shrink-0 items-center"> <span
<StatusDot color={color} label={label} /> class="hidden shrink-0 md:block {dotClass} h-4 w-4 rounded-full"
</span> title={label}
aria-label={label}
></span>

View File

@@ -6,63 +6,45 @@ import DocumentStatusChip from './DocumentStatusChip.svelte';
afterEach(cleanup); afterEach(cleanup);
describe('DocumentStatusChip', () => { describe('DocumentStatusChip', () => {
it('renders the placeholder label for PLACEHOLDER status', async () => { it('renders the placeholder label and gray dot for PLACEHOLDER status', async () => {
render(DocumentStatusChip, { props: { status: 'PLACEHOLDER' } }); render(DocumentStatusChip, { props: { status: 'PLACEHOLDER' } });
// CSS uppercase is visual only; DOM textContent returns the Paraglide string.
await expect.element(page.getByText('Platzhalter')).toBeInTheDocument(); const dot = await page.getByTitle('Platzhalter').element();
expect(dot.classList.contains('bg-gray-400')).toBe(true);
}); });
it('renders the uploaded label for UPLOADED status', async () => { it('renders the uploaded label and emerald dot for UPLOADED status', async () => {
render(DocumentStatusChip, { props: { status: 'UPLOADED' } }); render(DocumentStatusChip, { props: { status: 'UPLOADED' } });
await expect.element(page.getByText('Hochgeladen')).toBeInTheDocument();
const dot = await page.getByTitle('Hochgeladen').element();
expect(dot.classList.contains('bg-emerald-500')).toBe(true);
}); });
it('renders the transcribed label for TRANSCRIBED status', async () => { it('renders the transcribed label and blue dot for TRANSCRIBED status', async () => {
render(DocumentStatusChip, { props: { status: 'TRANSCRIBED' } }); render(DocumentStatusChip, { props: { status: 'TRANSCRIBED' } });
await expect.element(page.getByText('Transkribiert')).toBeInTheDocument();
const dot = await page.getByTitle('Transkribiert').element();
expect(dot.classList.contains('bg-blue-400')).toBe(true);
}); });
it('renders the reviewed label for REVIEWED status', async () => { it('renders the reviewed label and amber dot for REVIEWED status', async () => {
render(DocumentStatusChip, { props: { status: 'REVIEWED' } }); render(DocumentStatusChip, { props: { status: 'REVIEWED' } });
await expect.element(page.getByText('Geprüft')).toBeInTheDocument();
const dot = await page.getByTitle('Geprüft').element();
expect(dot.classList.contains('bg-amber-400')).toBe(true);
}); });
it('renders the archived label for ARCHIVED status', async () => { it('renders the archived label and dark emerald dot for ARCHIVED status', async () => {
render(DocumentStatusChip, { props: { status: 'ARCHIVED' } }); render(DocumentStatusChip, { props: { status: 'ARCHIVED' } });
await expect.element(page.getByText('Archiviert')).toBeInTheDocument();
const dot = await page.getByTitle('Archiviert').element();
expect(dot.classList.contains('bg-emerald-600')).toBe(true);
}); });
it('renders the dot as an aria-hidden element (decorative)', async () => { it('exposes the status as both a title tooltip and an aria-label', async () => {
render(DocumentStatusChip, { props: { status: 'UPLOADED' } }); render(DocumentStatusChip, { props: { status: 'UPLOADED' } });
const dot = document.querySelector('[aria-hidden="true"]');
expect(dot).not.toBeNull();
});
it('label AND dot are visible at all breakpoints — no hidden class on chip root', async () => { const dot = await page.getByTitle('Hochgeladen').element();
render(DocumentStatusChip, { props: { status: 'PLACEHOLDER' } }); expect(dot.getAttribute('aria-label')).toBe('Hochgeladen');
const root = document.querySelector('[data-testid="status-chip"]');
expect(root).not.toBeNull();
// The chip root must NOT have "hidden" class
expect(root?.className).not.toContain('hidden');
// And must not have md:block (which would hide on mobile)
expect(root?.className).not.toContain('md:block');
});
it('uses sage token for ARCHIVED status', async () => {
render(DocumentStatusChip, { props: { status: 'ARCHIVED' } });
const dot = document.querySelector('[aria-hidden="true"]');
expect(dot?.getAttribute('style')).toContain('var(--c-tag-sage)');
});
it('uses amber token for UPLOADED status', async () => {
render(DocumentStatusChip, { props: { status: 'UPLOADED' } });
const dot = document.querySelector('[aria-hidden="true"]');
expect(dot?.getAttribute('style')).toContain('var(--c-tag-amber)');
});
it('uses slate token for PLACEHOLDER status', async () => {
render(DocumentStatusChip, { props: { status: 'PLACEHOLDER' } });
const dot = document.querySelector('[aria-hidden="true"]');
expect(dot?.getAttribute('style')).toContain('var(--c-tag-slate)');
}); });
}); });

View File

@@ -9,7 +9,6 @@ import DocumentTopBarActions from './DocumentTopBarActions.svelte';
import DocumentMobileMenu from './DocumentMobileMenu.svelte'; import DocumentMobileMenu from './DocumentMobileMenu.svelte';
import BackButton from '$lib/shared/primitives/BackButton.svelte'; import BackButton from '$lib/shared/primitives/BackButton.svelte';
import type { DatePrecision } from '$lib/shared/utils/documentDate'; import type { DatePrecision } from '$lib/shared/utils/documentDate';
import type { DocumentStatus } from '$lib/document/documentStatusLabel';
type Person = { id: string; firstName?: string | null; lastName: string; displayName: string }; type Person = { id: string; firstName?: string | null; lastName: string; displayName: string };
type Tag = { id: string; name: string }; type Tag = { id: string; name: string };
@@ -27,7 +26,7 @@ type Doc = {
filePath?: string | null; filePath?: string | null;
contentType?: string | null; contentType?: string | null;
location?: string | null; location?: string | null;
status?: DocumentStatus | null; status?: string | null;
tags?: Tag[] | null; tags?: Tag[] | null;
hasTranscription?: boolean; hasTranscription?: boolean;
}; };

View File

@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'; import { describe, it, expect } from 'vitest';
import { formatDocumentStatus, statusDotColor } from './documentStatusLabel'; import { formatDocumentStatus, statusDotClass } from './documentStatusLabel';
describe('formatDocumentStatus', () => { describe('formatDocumentStatus', () => {
it('maps PLACEHOLDER to correct label', () => { it('maps PLACEHOLDER to correct label', () => {
@@ -27,24 +27,24 @@ describe('formatDocumentStatus', () => {
}); });
}); });
describe('statusDotColor — 5→3 semantic token mapping', () => { describe('statusDotClass', () => {
it('PLACEHOLDER → --c-tag-slate (new/draft)', () => { it('PLACEHOLDER → bg-gray-400', () => {
expect(statusDotColor('PLACEHOLDER')).toBe('var(--c-tag-slate)'); expect(statusDotClass('PLACEHOLDER')).toBe('bg-gray-400');
}); });
it('UPLOADED → --c-tag-amber (in-progress)', () => { it('UPLOADED → bg-emerald-500', () => {
expect(statusDotColor('UPLOADED')).toBe('var(--c-tag-amber)'); expect(statusDotClass('UPLOADED')).toBe('bg-emerald-500');
}); });
it('TRANSCRIBED → --c-tag-sage (done/confirmed)', () => { it('TRANSCRIBED → bg-blue-400', () => {
expect(statusDotColor('TRANSCRIBED')).toBe('var(--c-tag-sage)'); expect(statusDotClass('TRANSCRIBED')).toBe('bg-blue-400');
}); });
it('REVIEWED → --c-tag-sage (done/confirmed)', () => { it('REVIEWED → bg-amber-400', () => {
expect(statusDotColor('REVIEWED')).toBe('var(--c-tag-sage)'); expect(statusDotClass('REVIEWED')).toBe('bg-amber-400');
}); });
it('ARCHIVED → --c-tag-sage (done/confirmed)', () => { it('ARCHIVED → bg-emerald-600', () => {
expect(statusDotColor('ARCHIVED')).toBe('var(--c-tag-sage)'); expect(statusDotClass('ARCHIVED')).toBe('bg-emerald-600');
}); });
}); });

View File

@@ -19,23 +19,17 @@ export function formatDocumentStatus(status: string): string {
} }
} }
/** export function statusDotClass(status: DocumentStatus): string {
* Maps a DocumentStatus to a semantic `--c-tag-*` CSS custom-property string.
*
* 5→3 mapping (decided in issue #861):
* ARCHIVED / TRANSCRIBED / REVIEWED → --c-tag-sage (done / confirmed)
* UPLOADED → --c-tag-amber (in-progress)
* PLACEHOLDER → --c-tag-slate (new / draft)
*/
export function statusDotColor(status: DocumentStatus): string {
switch (status) { switch (status) {
case 'ARCHIVED':
case 'TRANSCRIBED':
case 'REVIEWED':
return 'var(--c-tag-sage)';
case 'UPLOADED':
return 'var(--c-tag-amber)';
case 'PLACEHOLDER': case 'PLACEHOLDER':
return 'var(--c-tag-slate)'; return 'bg-gray-400';
case 'UPLOADED':
return 'bg-emerald-500';
case 'TRANSCRIBED':
return 'bg-blue-400';
case 'REVIEWED':
return 'bg-amber-400';
case 'ARCHIVED':
return 'bg-emerald-600';
} }
} }

View File

@@ -0,0 +1,48 @@
<script lang="ts">
import type { Snippet } from 'svelte';
let {
eyebrow,
title,
lede,
right
}: {
eyebrow: string;
title: string;
lede?: string;
right?: Snippet;
} = $props();
</script>
<div
data-testid="page-header-wrapper"
style="margin-bottom:30px; display:flex; align-items:flex-end; justify-content:space-between; gap:24px; flex-wrap:wrap"
>
<div
data-testid="page-header-inner"
style="border-left:4px solid var(--c-accent); padding-left:18px"
>
<div
data-testid="page-header-eyebrow"
style="font-family:var(--font-sans); font-size:12px; font-weight:700; letter-spacing:.14em; text-transform:uppercase; color:var(--c-ink-3); margin-bottom:8px"
>
{eyebrow}
</div>
<h1
style="font-family:var(--font-serif); font-weight:700; font-size:clamp(28px,8vw,46px); line-height:1.06; color:var(--c-ink); margin:0"
>
{title}
</h1>
{#if lede}
<p
data-testid="page-header-lede"
style="font-family:var(--font-serif); font-style:italic; font-size:16px; color:var(--c-ink-2); margin:10px 0 0; max-width:520px"
>
{lede}
</p>
{/if}
</div>
{#if right}
{@render right()}
{/if}
</div>

View File

@@ -0,0 +1,135 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import PageHeader from './PageHeader.svelte';
afterEach(() => {
cleanup();
});
describe('PageHeader', () => {
// ── Structural / heading-hierarchy assertions ─────────────────────────
it('renders exactly one h1 containing the title', async () => {
render(PageHeader, { eyebrow: 'VERZEICHNIS', title: 'Personen' });
const headings = page.getByRole('heading', { level: 1 });
await expect.element(headings).toBeInTheDocument();
await expect.element(headings).toHaveTextContent('Personen');
});
it('renders the eyebrow as a non-heading element (div or span)', async () => {
render(PageHeader, { eyebrow: 'VERZEICHNIS', title: 'Personen' });
// The eyebrow must NOT be a heading of any level
const h1 = page.getByRole('heading', { level: 1 });
await expect.element(h1).toBeInTheDocument();
// No h2-h6 headings should be present
const h2 = page.getByRole('heading', { level: 2 });
await expect.element(h2).not.toBeInTheDocument();
});
it('renders eyebrow text content', async () => {
render(PageHeader, { eyebrow: 'PERSONENVERZEICHNIS', title: 'Personen' });
const eyebrow = page.getByTestId('page-header-eyebrow');
await expect.element(eyebrow).toHaveTextContent('PERSONENVERZEICHNIS');
});
it('renders lede when provided', async () => {
render(PageHeader, {
eyebrow: 'VERZEICHNIS',
title: 'Personen',
lede: 'Jede Hand, die schrieb oder genannt wurde.'
});
const lede = page.getByTestId('page-header-lede');
await expect.element(lede).toHaveTextContent('Jede Hand, die schrieb oder genannt wurde.');
});
it('does not render lede element when lede prop is omitted', async () => {
render(PageHeader, { eyebrow: 'VERZEICHNIS', title: 'Personen' });
const lede = page.getByTestId('page-header-lede');
await expect.element(lede).not.toBeInTheDocument();
});
// ── Right snippet ─────────────────────────────────────────────────────
it('renders the outer wrapper with page-header-wrapper test id', async () => {
render(PageHeader, {
eyebrow: 'VERZEICHNIS',
title: 'Personen'
});
const wrapper = page.getByTestId('page-header-wrapper');
await expect.element(wrapper).toBeInTheDocument();
});
// ── Content security: no @html ────────────────────────────────────────
it('escapes HTML in title (renders literal < as text not tags)', async () => {
render(PageHeader, { eyebrow: 'TEST', title: '<script>alert(1)</script>' });
const h1 = page.getByRole('heading', { level: 1 });
// The heading content should be the literal string, not interpreted HTML
await expect.element(h1).toHaveTextContent('<script>alert(1)</script>');
});
it('escapes HTML in eyebrow', async () => {
render(PageHeader, { eyebrow: '<b>BOLD</b>', title: 'Personen' });
const eyebrow = page.getByTestId('page-header-eyebrow');
await expect.element(eyebrow).toHaveTextContent('<b>BOLD</b>');
});
// ── Design tokens / style ─────────────────────────────────────────────
it('h1 has font-size set to the clamp expression', async () => {
render(PageHeader, { eyebrow: 'VERZEICHNIS', title: 'Personen' });
const h1 = page.getByRole('heading', { level: 1 });
// The inline style must carry the clamp — computed value on a 1024px viewport
// with clamp(28px,8vw,46px) → 8vw = 81.92px > 46px → capped at 46px
const el = h1.element() as HTMLElement;
const fs = el.style.fontSize || getComputedStyle(el).fontSize;
expect(fs).toMatch(/clamp|46px|28px/);
});
it('wrapper has data-testid page-header-wrapper', async () => {
render(PageHeader, { eyebrow: 'VERZEICHNIS', title: 'Personen' });
const wrapper = page.getByTestId('page-header-wrapper');
await expect.element(wrapper).toBeInTheDocument();
});
it('inner container inline style includes the 4px accent left border and 18px padding', async () => {
render(PageHeader, { eyebrow: 'VERZEICHNIS', title: 'Personen' });
const inner = page.getByTestId('page-header-inner');
const el = inner.element() as HTMLElement;
const styleAttr = el.getAttribute('style') ?? '';
expect(styleAttr).toContain('border-left:4px solid var(--c-accent)');
expect(styleAttr).toContain('padding-left:18px');
});
// ── Edit/detail eyebrow context (generic prop) ────────────────────────
it('accepts different eyebrow texts for list and edit context', async () => {
const { unmount } = render(PageHeader, {
eyebrow: 'PERSON BEARBEITEN',
title: 'Herbert Cram'
});
const eyebrow = page.getByTestId('page-header-eyebrow');
await expect.element(eyebrow).toHaveTextContent('PERSON BEARBEITEN');
unmount();
render(PageHeader, { eyebrow: 'PERSONENVERZEICHNIS', title: 'Personen' });
const eyebrow2 = page.getByTestId('page-header-eyebrow');
await expect.element(eyebrow2).toHaveTextContent('PERSONENVERZEICHNIS');
});
});

View File

@@ -1,31 +0,0 @@
<script lang="ts">
/**
* StatusDot — shared primitive (§7, issue #861).
*
* Dumb renderer: props only, no domain imports.
* - `color`: a CSS custom-property string, e.g. `var(--c-tag-sage)`
* - `label`: plain string (from Paraglide, never raw user input)
*
* The dot is aria-hidden (decorative once the visible text label is present).
* Label uses var(--c-ink-2) — NEVER the status hue (amber at 10px fails AA).
* No import from $lib/document/ — eslint-boundaries shared→document is forbidden.
*/
type Props = {
color: string;
label: string;
};
let { color, label }: Props = $props();
</script>
<span class="inline-flex items-center gap-1.5">
<span
aria-hidden="true"
style="background-color: {color}; width: 7px; height: 7px; border-radius: 9999px; flex-shrink: 0; display: inline-block;"
></span>
<span
data-testid="status-dot-label"
class="font-sans text-[10px] font-bold tracking-[.13em] text-ink-2 uppercase">{label}</span
>
</span>

View File

@@ -1,61 +0,0 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import StatusDot from './StatusDot.svelte';
afterEach(() => cleanup());
describe('StatusDot', () => {
it('renders the label text', async () => {
render(StatusDot, { color: 'var(--c-tag-sage)', label: 'Archiviert' });
await expect.element(page.getByText('Archiviert')).toBeInTheDocument();
});
it('renders the dot as aria-hidden decorative element', async () => {
render(StatusDot, { color: 'var(--c-tag-amber)', label: 'Hochgeladen' });
const dot = document.querySelector('[aria-hidden="true"]');
expect(dot).not.toBeNull();
});
it('applies the color token via background-color style on the dot', async () => {
render(StatusDot, { color: 'var(--c-tag-slate)', label: 'Platzhalter' });
const dot = document.querySelector('[aria-hidden="true"]');
expect(dot?.getAttribute('style')).toContain('var(--c-tag-slate)');
});
it('renders label text via text node — never via innerHTML', async () => {
render(StatusDot, { color: 'var(--c-tag-sage)', label: 'Transkribiert' });
// CSS uppercase is visual only; textContent returns the original string.
// We verify the DOM text is present via the normal text node (no XSS risk).
const textEl = document.querySelector('[data-testid="status-dot-label"]');
expect(textEl).not.toBeNull();
expect(textEl?.textContent?.trim()).toBe('Transkribiert');
});
it('dot is 7px wide and tall (circle)', async () => {
render(StatusDot, { color: 'var(--c-tag-sage)', label: 'Archiviert' });
const dot = document.querySelector('[aria-hidden="true"]');
// Size is set via inline style — verify dot has no text content (it is a pure visual circle)
expect(dot?.textContent?.trim()).toBe('');
});
it('label uses ink-2 color class, not status hue', async () => {
render(StatusDot, { color: 'var(--c-tag-amber)', label: 'Hochgeladen' });
const label = document.querySelector('[data-testid="status-dot-label"]');
// Should carry text-ink-2 class for color
expect(label?.className).toContain('text-ink-2');
});
it('label is uppercase Montserrat', async () => {
render(StatusDot, { color: 'var(--c-tag-sage)', label: 'Geprüft' });
const label = document.querySelector('[data-testid="status-dot-label"]');
expect(label?.className).toContain('font-sans');
expect(label?.className).toContain('uppercase');
});
it('does not import from $lib/document — is truly shared', () => {
// This is a structural/lint test. The fact it compiles without error when
// imported here (from shared/) is the proof. Eslint-boundaries enforces this.
expect(true).toBe(true);
});
});

View File

@@ -7,7 +7,7 @@ import { m } from '$lib/paraglide/messages.js';
import PersonCard from '$lib/person/PersonCard.svelte'; import PersonCard from '$lib/person/PersonCard.svelte';
import PersonFilterBar from '$lib/person/PersonFilterBar.svelte'; import PersonFilterBar from '$lib/person/PersonFilterBar.svelte';
import Pagination from '$lib/shared/primitives/Pagination.svelte'; import Pagination from '$lib/shared/primitives/Pagination.svelte';
import PersonsStatsBar from './PersonsStatsBar.svelte'; import PageHeader from '$lib/shared/primitives/PageHeader.svelte';
import PersonsEmptyState from './PersonsEmptyState.svelte'; import PersonsEmptyState from './PersonsEmptyState.svelte';
let { data } = $props(); let { data } = $props();
@@ -53,71 +53,62 @@ const noFiltersActive = $derived(
</svelte:head> </svelte:head>
<div class="mx-auto max-w-7xl px-4 py-12 sm:px-6 lg:px-8"> <div class="mx-auto max-w-7xl px-4 py-12 sm:px-6 lg:px-8">
<!-- Header: title+stats on left, search+CTA on right --> <PageHeader eyebrow={m.persons_eyebrow()} title={m.page_title_persons()} lede={m.persons_lede()}>
<div class="mb-6 flex flex-wrap items-end justify-between gap-4 border-b border-ink/10 pb-6"> {#snippet right()}
<div> <div class="flex shrink-0 items-center gap-3">
<h1 class="font-serif text-3xl font-medium text-ink">{m.page_title_persons()}</h1> <!-- Search -->
<div class="mt-2"> <div class="relative">
<PersonsStatsBar <label for="search" class="sr-only">{m.persons_search_placeholder()}</label>
totalPersons={data.stats.totalPersons ?? 0} <input
totalDocuments={data.stats.totalDocuments ?? 0} id="search"
/> type="text"
</div> placeholder={m.persons_search_placeholder()}
</div> bind:value={q}
oninput={handleSearch}
<div class="flex items-center gap-3"> onfocus={() => (qFocused = true)}
<!-- Search --> onblur={() => (qFocused = false)}
<div class="relative"> class="block w-56 rounded-sm border border-line bg-surface py-2.5 pr-10 pl-4 font-sans text-sm text-ink placeholder-ink-3 shadow-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"
<label for="search" class="sr-only">{m.persons_search_placeholder()}</label>
<input
id="search"
type="text"
placeholder={m.persons_search_placeholder()}
bind:value={q}
oninput={handleSearch}
onfocus={() => (qFocused = true)}
onblur={() => (qFocused = false)}
class="block w-56 rounded-sm border border-line bg-surface py-2.5 pr-10 pl-4 font-sans text-sm text-ink placeholder-ink-3 shadow-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"
/>
<div
class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3 text-ink-3"
>
<img
src="/degruyter-icons/Simple/Medium-24px/SVG/Action/Mag-Glass-MD.svg"
alt=""
aria-hidden="true"
class="h-4 w-4 opacity-40"
/> />
<div
class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3 text-ink-3"
>
<img
src="/degruyter-icons/Simple/Medium-24px/SVG/Action/Mag-Glass-MD.svg"
alt=""
aria-hidden="true"
class="h-4 w-4 opacity-40"
/>
</div>
</div> </div>
<!-- Triage link (transcriber only) -->
{#if data.canWrite}
<a
href="/persons/review"
class="inline-flex min-h-[44px] items-center gap-1.5 rounded-sm border border-line bg-surface px-4 py-2 font-sans text-sm font-semibold text-ink transition-colors hover:bg-muted"
>
{m.persons_toggle_needs_review({ count: data.needsReviewCount })}
</a>
{/if}
<!-- New person CTA -->
{#if data.canWrite}
<a
href="/persons/new"
class="inline-flex min-h-[44px] items-center gap-1.5 rounded-sm bg-primary px-4 py-2.5 font-sans text-sm font-bold tracking-wide text-primary-fg transition-colors hover:bg-primary/80"
>
<img
src="/degruyter-icons/Simple/Medium-24px/SVG/Action/Add/Add-General-MD.svg"
alt=""
aria-hidden="true"
class="h-4 w-4 invert dark:invert-0"
/>
{m.persons_btn_new()}
</a>
{/if}
</div> </div>
{/snippet}
<!-- Triage link (transcriber only) --> </PageHeader>
{#if data.canWrite}
<a
href="/persons/review"
class="inline-flex min-h-[44px] items-center gap-1.5 rounded-sm border border-line bg-surface px-4 py-2 font-sans text-sm font-semibold text-ink transition-colors hover:bg-muted"
>
{m.persons_toggle_needs_review({ count: data.needsReviewCount })}
</a>
{/if}
<!-- New person CTA -->
{#if data.canWrite}
<a
href="/persons/new"
class="inline-flex min-h-[44px] items-center gap-1.5 rounded-sm bg-primary px-4 py-2.5 font-sans text-sm font-bold tracking-wide text-primary-fg transition-colors hover:bg-primary/80"
>
<img
src="/degruyter-icons/Simple/Medium-24px/SVG/Action/Add/Add-General-MD.svg"
alt=""
aria-hidden="true"
class="h-4 w-4 invert dark:invert-0"
/>
{m.persons_btn_new()}
</a>
{/if}
</div>
</div>
<!-- Filter chips + show-all toggle --> <!-- Filter chips + show-all toggle -->
<div class="mb-8"> <div class="mb-8">

View File

@@ -1,10 +1,9 @@
<script lang="ts"> <script lang="ts">
import { m } from '$lib/paraglide/messages.js'; import { m } from '$lib/paraglide/messages.js';
import { formatDate } from '$lib/shared/utils/date'; import { formatDate } from '$lib/shared/utils/date';
import { formatDocumentStatus } from '$lib/document/documentStatusLabel';
import { sortDocumentsByDate, type SortDir } from '$lib/shared/utils/sort'; import { sortDocumentsByDate, type SortDir } from '$lib/shared/utils/sort';
import DocumentThumbnail from '$lib/document/DocumentThumbnail.svelte'; import DocumentThumbnail from '$lib/document/DocumentThumbnail.svelte';
import DocumentStatusChip from '$lib/document/DocumentStatusChip.svelte';
import type { DocumentStatus } from '$lib/document/documentStatusLabel';
const DOCS_PREVIEW_LIMIT = 5; const DOCS_PREVIEW_LIMIT = 5;
@@ -19,7 +18,7 @@ let {
originalFilename: string; originalFilename: string;
documentDate?: string | null; documentDate?: string | null;
location?: string | null; location?: string | null;
status: DocumentStatus; status: string;
contentType?: string; contentType?: string;
thumbnailUrl?: string; thumbnailUrl?: string;
}[]; }[];
@@ -95,8 +94,17 @@ const visibleDocuments = $derived(
</div> </div>
</div> </div>
<!-- Status chip — always visible at all breakpoints --> <!-- Status chip -->
<DocumentStatusChip status={doc.status} /> <span
class="hidden flex-shrink-0 rounded-full border px-2 py-0.5 font-sans text-[10px] font-bold sm:inline-block
{doc.status === 'UPLOADED'
? 'border-accent/50 bg-accent/20 text-ink'
: doc.status === 'ARCHIVED'
? 'border-green-200 bg-green-50 text-green-800'
: 'border-yellow-200 bg-yellow-50 text-yellow-800'}"
>
{formatDocumentStatus(doc.status)}
</span>
<img <img
src="/degruyter-icons/Simple/Medium-24px/SVG/Action/Arrow/Arrow-Right-MD.svg" src="/degruyter-icons/Simple/Medium-24px/SVG/Action/Arrow/Arrow-Right-MD.svg"

View File

@@ -2,7 +2,6 @@ import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte'; import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser'; import { page } from 'vitest/browser';
import PersonDocumentList from './PersonDocumentList.svelte'; import PersonDocumentList from './PersonDocumentList.svelte';
import type { DocumentStatus } from '$lib/document/documentStatusLabel';
afterEach(cleanup); afterEach(cleanup);
@@ -12,7 +11,7 @@ const makeDoc = (overrides: Record<string, unknown> = {}) => ({
originalFilename: 'brief.pdf', originalFilename: 'brief.pdf',
documentDate: '1923-04-15', documentDate: '1923-04-15',
location: 'Berlin', location: 'Berlin',
status: 'UPLOADED' as DocumentStatus, status: 'UPLOADED' as string,
contentType: 'application/pdf', contentType: 'application/pdf',
thumbnailUrl: '', thumbnailUrl: '',
...overrides ...overrides