From 00682bac4fe6c865b9edb4a325c80406997c905e Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 8 May 2026 10:04:38 +0200 Subject: [PATCH] refactor(documents): extract TimelineBars from density filter (#385) Splits the bar row + drag-window overlay + bar styling out of the 377-line orchestrator into a single-purpose component. The pointer choreography (handle{PointerDown,DocumentMove,DocumentUp}, indexFromClientX, cleanupDragListeners) stays in the orchestrator per Felix's note. Closes part 1 of Felix's component-split concern. Co-Authored-By: Claude Opus 4.7 --- frontend/src/lib/document/TimelineBars.svelte | 131 ++++++++++++++++++ .../lib/document/TimelineDensityFilter.svelte | 108 ++------------- 2 files changed, 146 insertions(+), 93 deletions(-) create mode 100644 frontend/src/lib/document/TimelineBars.svelte diff --git a/frontend/src/lib/document/TimelineBars.svelte b/frontend/src/lib/document/TimelineBars.svelte new file mode 100644 index 00000000..6e288820 --- /dev/null +++ b/frontend/src/lib/document/TimelineBars.svelte @@ -0,0 +1,131 @@ + + +
+ {#each filled as bucket, i (bucket.month)} + + {/each} + {#if isDragging} +
+ {/if} +
+ + diff --git a/frontend/src/lib/document/TimelineDensityFilter.svelte b/frontend/src/lib/document/TimelineDensityFilter.svelte index 5d5e4554..906aab86 100644 --- a/frontend/src/lib/document/TimelineDensityFilter.svelte +++ b/frontend/src/lib/document/TimelineDensityFilter.svelte @@ -10,6 +10,7 @@ import { formatTickLabel } from '$lib/document/timeline'; import { getLocale } from '$lib/paraglide/runtime'; +import TimelineBars from '$lib/document/TimelineBars.svelte'; import type { components } from '$lib/generated/api'; type MonthBucket = components['schemas']['MonthBucket']; @@ -24,7 +25,6 @@ type SelectionEvent = { type ZoomEvent = { zoomFrom: string; zoomTo: string }; const BAR_AREA_HEIGHT = 80; // px — Leonie spec h-20 -const ZERO_COUNT_BAR_HEIGHT = 2; // px — minimum visible signal for empty months // Above this threshold, month bars compress to sub-pixel widths in the flex // row; we collapse to year granularity so each bar stays clickable. const MONTH_GRANULARITY_LIMIT = 240; @@ -91,11 +91,6 @@ const dragHighIndex = $derived( : dragStartIndex ); -function barHeight(count: number): number { - if (count === 0) return ZERO_COUNT_BAR_HEIGHT; - return Math.max(ZERO_COUNT_BAR_HEIGHT, (count / maxCount) * BAR_AREA_HEIGHT); -} - function clearSelection() { onchange({ from: '', to: '' }); } @@ -264,41 +259,20 @@ const omitTickYear = $derived.by(() => {
-
- {#each filled as bucket, i (bucket.month)} - - {/each} - {#if isDragging} -
- {/if} -
+
{
{/if} - -