feat(timeline): add eventCardConfig accent matrix + DTO test factories

getAccentConfig(entry) maps each EVENT to its glyph (* / † / ⚭ / ★ / ◍), German
redundant-cue label, and accent kind (REQ-007/008/018). test-factories build
TimelineEntryDTO/TimelineDTO mirroring the real wire shape for component specs.

Refs #779
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-13 19:26:29 +02:00
parent 607112afc2
commit 6a35e8510b
3 changed files with 125 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import * as m from '$lib/paraglide/messages.js';
import type { components } from '$lib/generated/api';
type TimelineEntryDTO = components['schemas']['TimelineEntryDTO'];
/** Styling discriminant for an axis pill/band. */
export type TimelineAccent = 'derived' | 'curated' | 'historical';
export interface AccentConfig {
/** Visible Unicode glyph — render `aria-hidden`, paired with an sr-only label. */
glyph: string;
/** German layer/life-event label — used as the sr-only text and as visible chrome. */
label: string;
accent: TimelineAccent;
}
/**
* Maps a timeline EVENT entry to its glyph, redundant non-color label, and accent
* (REQ-007/008/018). Derived life-events use the * / † / ⚭ glyphs that match
* `personLifeDates.ts`; HISTORICAL events get the muted world band; everything
* else (curated PERSONAL) gets the mint family pill.
*/
export function getAccentConfig(entry: TimelineEntryDTO): AccentConfig {
if (entry.derived) {
switch (entry.derivedType) {
case 'BIRTH':
return { glyph: '*', label: m.timeline_derived_birth(), accent: 'derived' };
case 'DEATH':
return { glyph: '†', label: m.timeline_derived_death(), accent: 'derived' };
case 'MARRIAGE':
return { glyph: '⚭', label: m.timeline_derived_marriage(), accent: 'derived' };
}
}
if (entry.type === 'HISTORICAL') {
return { glyph: '◍', label: m.timeline_layer_world(), accent: 'historical' };
}
return { glyph: '★', label: m.timeline_layer_family(), accent: 'curated' };
}