From 59a2faa145598051fbff883ceaa3a3a426247951 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 7 May 2026 22:54:02 +0200 Subject: [PATCH] fix(documents): collapse timeline to year bars when range > 240 months (#385) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Surfaced during proofshot: the production archive spans 1873 → 2023 (≈1809 month bars). With flex-1 + gap-px on a 1280 px container, every pixel was consumed by gaps and bars rendered at 0 px width — visible as "empty box, no bars". Fix: - Add aggregateToYears(buckets) that sums month counts per year and returns YYYY-keyed entries. - Add selectionBoundaryFrom/To that handle both YYYY and YYYY-MM labels (Jan 1 → Dec 31 for years, first → last day for months). - Component switches to year granularity when the gap-filled month sequence exceeds 240 entries (~20 years), keeping each bar clickable. - Drop the gap-px between bars and add min-w-px so sub-pixel rounding still leaves something visible. 5 new tests cover aggregation, boundary helpers, and the component-level year-mode + click behaviour. Co-Authored-By: Claude Sonnet 4.6 --- .../lib/document/TimelineDensityFilter.svelte | 32 +++++++++---- .../TimelineDensityFilter.svelte.spec.ts | 43 +++++++++++++++++ frontend/src/lib/document/timeline.spec.ts | 46 ++++++++++++++++++- frontend/src/lib/document/timeline.ts | 29 ++++++++++++ 4 files changed, 139 insertions(+), 11 deletions(-) diff --git a/frontend/src/lib/document/TimelineDensityFilter.svelte b/frontend/src/lib/document/TimelineDensityFilter.svelte index 1d9b9cf1..9a4866b0 100644 --- a/frontend/src/lib/document/TimelineDensityFilter.svelte +++ b/frontend/src/lib/document/TimelineDensityFilter.svelte @@ -1,6 +1,11 @@ @@ -61,15 +73,15 @@ function isSelected(month: string): boolean { aria-label={m.timeline_aria_label()} class="relative rounded-sm border border-line bg-surface px-3 pt-3 pb-2 shadow-sm" > -
+
{#each filled as bucket (bucket.month)}