refactor(person): fold year range into section headings, remove standalone stats bar
The floating stats bar was visually disconnected and showed a combined document count already visible from the per-section badges. Replaced it with a year range shown inline next to each section heading (e.g. "Gesendete Dokumente · 12 · 1921–1945"), making the range contextually relevant per direction. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,15 +24,18 @@
|
||||
|
||||
const allDocuments = $derived([...sentDocuments, ...receivedDocuments]);
|
||||
|
||||
const docStats = $derived(() => {
|
||||
const dated = allDocuments.filter(d => d.documentDate);
|
||||
const years = dated.map(d => parseInt(d.documentDate!.substring(0, 4)));
|
||||
return {
|
||||
total: allDocuments.length,
|
||||
minYear: years.length ? Math.min(...years) : null,
|
||||
maxYear: years.length ? Math.max(...years) : null,
|
||||
};
|
||||
});
|
||||
function yearRange(docs: typeof sentDocuments) {
|
||||
const years = docs
|
||||
.filter(d => d.documentDate)
|
||||
.map(d => parseInt(d.documentDate!.substring(0, 4)));
|
||||
if (!years.length) return null;
|
||||
const min = Math.min(...years);
|
||||
const max = Math.max(...years);
|
||||
return min === max ? `${min}` : `${min} – ${max}`;
|
||||
}
|
||||
|
||||
const sentYearRange = $derived(yearRange(sentDocuments));
|
||||
const receivedYearRange = $derived(yearRange(receivedDocuments));
|
||||
|
||||
const coCorrespondents = $derived(() => {
|
||||
const freq = new Map<string, { id: string; name: string; count: number }>();
|
||||
@@ -327,21 +330,6 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Document Statistics Bar -->
|
||||
{#if docStats().total > 0}
|
||||
<div class="mb-8 px-4 py-3 bg-brand-sand/30 rounded-sm flex items-center gap-2 font-sans text-sm text-brand-navy/70">
|
||||
<span>{docStats().total} Dokumente</span>
|
||||
{#if docStats().minYear !== null}
|
||||
<span class="text-brand-mint">·</span>
|
||||
{#if docStats().minYear === docStats().maxYear}
|
||||
<span>{docStats().minYear}</span>
|
||||
{:else}
|
||||
<span>{docStats().minYear} – {docStats().maxYear}</span>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Sort control -->
|
||||
{#if allDocuments.length > 0}
|
||||
<div class="flex justify-end mb-4">
|
||||
@@ -362,6 +350,9 @@
|
||||
<span class="bg-brand-navy text-white text-xs font-bold px-2 py-1 rounded-full">
|
||||
{sentDocuments.length}
|
||||
</span>
|
||||
{#if sentYearRange}
|
||||
<span class="text-xs font-sans text-gray-400">{sentYearRange}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if sentDocuments.length === 0}
|
||||
@@ -423,6 +414,9 @@
|
||||
<span class="bg-brand-navy text-white text-xs font-bold px-2 py-1 rounded-full">
|
||||
{receivedDocuments.length}
|
||||
</span>
|
||||
{#if receivedYearRange}
|
||||
<span class="text-xs font-sans text-gray-400">{receivedYearRange}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if receivedDocuments.length === 0}
|
||||
|
||||
Reference in New Issue
Block a user