feat(person): render precise life dates on cards, hover card, and mention dropdown

Cards compose aria-hidden * / † glyphs in markup so screen readers only
announce the dates; PersonSummaryDTO list card stays year-shaped by
design (ADR-039). MentionDropdown subtitle wraps instead of truncating
so DAY-precision ranges fit at 320px.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-12 18:14:20 +02:00
committed by marcel
parent adac1b1f99
commit 0e7095fee6
10 changed files with 254 additions and 33 deletions

View File

@@ -306,6 +306,12 @@ function selectItem(item: Person) {
</a>
{:else}
{#each model.items as person, i (person.id)}
{@const lifeDates = formatLifeDateRange(
person.birthDate,
person.birthDatePrecision,
person.deathDate,
person.deathDatePrecision
)}
<div
class={[
'flex min-h-[44px] cursor-pointer flex-col gap-1 px-3 py-2.5 text-left hover:bg-canvas',
@@ -325,9 +331,11 @@ function selectItem(item: Person) {
}}
>
<span class="truncate font-serif text-base text-ink">{person.displayName}</span>
{#if formatLifeDateRange(person.birthYear, person.deathYear)}
<span class="truncate font-sans text-xs text-ink-3">
{formatLifeDateRange(person.birthYear, person.deathYear)}
{#if lifeDates}
<!-- whitespace-normal: a DAY-precision range (~37 chars) wraps to a second
line at 320px instead of being clipped by truncate. -->
<span class="font-sans text-xs whitespace-normal text-ink-3">
{lifeDates}
</span>
{/if}
</div>

View File

@@ -103,11 +103,18 @@ describe('MentionDropdown', () => {
expect(option?.getAttribute('aria-selected')).toBe('true');
});
it('renders the life-date range when birthYear or deathYear is present', async () => {
it('renders the life-date range when birth or death date is present', async () => {
render(MentionDropdown, {
props: {
model: baseModel({
items: [makePerson('p1', 'Anna', { birthYear: 1899, deathYear: 1972 })]
items: [
makePerson('p1', 'Anna', {
birthDate: '1899-01-01',
birthDatePrecision: 'YEAR',
deathDate: '1972-01-01',
deathDatePrecision: 'YEAR'
})
]
})
}
});
@@ -115,6 +122,25 @@ describe('MentionDropdown', () => {
await expect.element(page.getByText(/1899/)).toBeVisible();
});
it('renders a DAY-precision birth date as a full date without clipping it away', async () => {
render(MentionDropdown, {
props: {
model: baseModel({
items: [
makePerson('p1', 'Anna', {
birthDate: '1901-03-14',
birthDatePrecision: 'DAY',
deathDate: '1944-11-02',
deathDatePrecision: 'DAY'
})
]
})
}
});
await expect.element(page.getByText(/14\. März 1901/)).toBeVisible();
});
it('falls back to a default position when clientRect returns null', async () => {
render(MentionDropdown, {
props: {

View File

@@ -35,8 +35,10 @@ const AUGUSTE: Person = {
personType: 'PERSON',
familyMember: false,
provisional: false,
birthYear: 1882,
deathYear: 1944
birthDate: '1882-01-01',
birthDatePrecision: 'YEAR',
deathDate: '1944-01-01',
deathDatePrecision: 'YEAR'
};
const ANNA: Person = {
@@ -47,7 +49,8 @@ const ANNA: Person = {
personType: 'PERSON',
familyMember: false,
provisional: false,
birthYear: 1860
birthDate: '1860-01-01',
birthDatePrecision: 'YEAR'
};
function mockFetchWithPersons(persons: Person[] = [AUGUSTE, ANNA]) {