diff --git a/frontend/src/lib/timeline/LetterCard.svelte b/frontend/src/lib/timeline/LetterCard.svelte index 84a76bfb..df586f79 100644 --- a/frontend/src/lib/timeline/LetterCard.svelte +++ b/frontend/src/lib/timeline/LetterCard.svelte @@ -21,11 +21,21 @@ type TimelineEntryDTO = components['schemas']['TimelineEntryDTO']; let { entry, variant = 'plain', - suppressTagChip = false -}: { entry: TimelineEntryDTO; variant?: 'plain' | 'event'; suppressTagChip?: boolean } = $props(); + suppressTagChip = false, + compact = false +}: { + entry: TimelineEntryDTO; + variant?: 'plain' | 'event'; + suppressTagChip?: boolean; + compact?: boolean; +} = $props(); const isEventVariant = $derived(variant === 'event'); const dateLabel = $derived(timelineDateLabel(entry.eventDate, entry.precision, entry.eventDateEnd)); +// Inside a per-year bucket the year frames the time, and these archive titles already +// embed the date — so the compact in-bucket card drops the redundant date chip when a +// title is present, halving the row height and killing the duplicate date (#827). +const showDate = $derived(!compact || !entry.title); const sender = $derived(entry.senderName === '' ? m.timeline_unknown_person() : entry.senderName); const receiver = $derived( entry.receiverName === '' ? m.timeline_unknown_person() : entry.receiverName @@ -38,23 +48,30 @@ const receiver = $derived( {#if entry.title} - + {entry.title} {/if} - + {sender} {receiver} - {#if dateLabel} + {#if dateLabel && showDate} · {dateLabel} {/if} diff --git a/frontend/src/lib/timeline/LetterCard.svelte.spec.ts b/frontend/src/lib/timeline/LetterCard.svelte.spec.ts index df36bffc..7821ff7e 100644 --- a/frontend/src/lib/timeline/LetterCard.svelte.spec.ts +++ b/frontend/src/lib/timeline/LetterCard.svelte.spec.ts @@ -151,4 +151,22 @@ describe('LetterCard — grouping variants (#827, REQ-014/017)', () => { render(LetterCard, { entry: makeEntry({ rootTagName: 'Krieg', rootTagColor: 'sienna' }) }); expect(document.querySelector('[data-testid="tag-chip"]')).not.toBeNull(); }); + + it('drops the redundant date line in the compact variant when a title is present (#827)', () => { + // Inside a per-year bucket the year already frames the time, and these archive + // titles embed the date — so the compact in-bucket card omits the date chip. + render(LetterCard, { entry: makeEntry({ title: 'H-0023 – 6. Juli 1916' }), compact: true }); + expect(document.querySelector('[data-testid="letter-date"]')).toBeNull(); + expect(document.body.textContent).toContain('Karl Raddatz'); // sender still shown + }); + + it('keeps the date in the compact variant when the letter has no title (#827)', () => { + render(LetterCard, { entry: makeEntry({ title: undefined }), compact: true }); + expect(document.querySelector('[data-testid="letter-date"]')).not.toBeNull(); + }); + + it('renders the compact variant on a single tighter row (#827)', () => { + render(LetterCard, { entry: makeEntry(), compact: true }); + expect(document.querySelector('a.lcard.compact')).not.toBeNull(); + }); });