refine timeline topic legend layout

This commit is contained in:
2026-06-22 23:31:27 +02:00
parent e8c0144441
commit 38896304e8
3 changed files with 162 additions and 97 deletions
@@ -12,56 +12,71 @@
class="subfield-legend"
[class.expanded]="subfieldLegendExpanded"
aria-label="Aktuell sichtbare Subfields">
<div
*ngFor="
let group of subfieldLegendGroups;
trackBy: trackByLegendGroup
"
class="subfield-legend-group">
<span class="subfield-legend-field">{{ group.name }}</span>
<div class="subfield-legend-header">
<div class="subfield-legend-title">
<span>Farben nach Subfield</span>
<mat-icon
class="subfield-legend-info"
matTooltip="Fields geben die Farbfamilie vor, Subfields bestimmen die konkrete Farbvariante."
matTooltipPosition="above"
aria-label="Informationen zur Farblegende">
info_outline
</mat-icon>
</div>
<span class="subfield-legend-items">
<span
*ngFor="let item of group.items; trackBy: trackByLegendItem"
class="subfield-legend-item">
<span
class="subfield-legend-dot"
[style.background]="item.color"
aria-hidden="true"></span>
<span>{{ item.name }}</span>
<button
type="button"
class="subfield-legend-visibility-toggle"
[attr.aria-expanded]="subfieldLegendVisible"
(click)="toggleSubfieldLegendVisibility()">
<span>
{{
subfieldLegendVisible
? 'Legende ausblenden'
: 'Legende einblenden'
}}
</span>
</span>
<mat-icon aria-hidden="true">
{{ subfieldLegendVisible ? 'expand_less' : 'expand_more' }}
</mat-icon>
</button>
</div>
<button
*ngIf="showSubfieldLegendToggle"
type="button"
class="subfield-legend-toggle"
(click)="toggleSubfieldLegend()">
{{
subfieldLegendExpanded
? 'Weniger anzeigen'
: hiddenSubfieldLegendItemCount + ' weitere anzeigen'
}}
</button>
</div>
<div *ngIf="subfieldLegendVisible" class="subfield-legend-content">
<div
*ngFor="
let group of subfieldLegendGroups;
trackBy: trackByLegendGroup
"
class="subfield-legend-group">
<span class="subfield-legend-field">{{ group.name }}</span>
<button
*ngIf="
showEarlierYearsControl &&
timelineViewMode === 'compact' &&
!loading &&
!loadFailed
"
type="button"
class="load-more-action-button"
[disabled]="loadingEarlierYears"
(click)="requestEarlierYears()">
<span class="load-more-content">
<mat-spinner *ngIf="loadingEarlierYears" diameter="16"></mat-spinner>
<span>{{ earlierYearsLabel }}</span>
</span>
</button>
<span class="subfield-legend-items">
<span
*ngFor="let item of group.items; trackBy: trackByLegendItem"
class="subfield-legend-item">
<span
class="subfield-legend-dot"
[style.background]="item.color"
aria-hidden="true"></span>
<span>{{ item.name }}</span>
</span>
</span>
</div>
<button
*ngIf="showSubfieldLegendToggle"
type="button"
class="subfield-legend-more-toggle"
(click)="toggleSubfieldLegend()">
{{
subfieldLegendExpanded
? 'Weniger anzeigen'
: '+' + hiddenSubfieldLegendItemCount + ' weitere'
}}
</button>
</div>
</div>
<span
*ngIf="
@@ -316,6 +331,21 @@
</ng-container>
<ng-template #compactTimeline>
<div *ngIf="showEarlierYearsControl" class="compact-load-more-row">
<button
type="button"
class="load-more-action-button"
[disabled]="loadingEarlierYears"
(click)="requestEarlierYears()">
<span class="load-more-content">
<mat-spinner
*ngIf="loadingEarlierYears"
diameter="16"></mat-spinner>
<span>{{ earlierYearsLabel }}</span>
</span>
</button>
</div>
<div class="compact-phase-list">
<article
*ngFor="let phase of compactPhases; trackBy: trackByPhase"
@@ -65,21 +65,80 @@
}
.subfield-legend {
width: min(760px, 100%);
box-sizing: border-box;
margin-top: 16px;
padding: 13px 16px;
border: 1px solid #dbe5f6;
border-radius: 8px;
background: #ffffff;
}
.subfield-legend-header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 16px;
}
.subfield-legend-title,
.subfield-legend-visibility-toggle,
.subfield-legend-content,
.subfield-legend-group,
.subfield-legend-items,
.subfield-legend-item {
display: flex;
align-items: center;
}
.subfield-legend-title {
gap: 5px;
color: #07163d;
font-size: 12px;
font-weight: 800;
line-height: 1.25;
}
.subfield-legend-info {
width: 14px;
height: 14px;
color: #7d8aa8;
font-size: 14px;
line-height: 14px;
}
.subfield-legend-visibility-toggle {
flex: 0 0 auto;
gap: 4px;
color: var(--accent);
font-size: 11px;
font-weight: 700;
line-height: 1.2;
mat-icon {
width: 14px;
height: 14px;
font-size: 14px;
line-height: 14px;
}
&:hover {
text-decoration: none;
}
}
.subfield-legend-content {
flex-wrap: wrap;
gap: 8px;
max-width: 760px;
margin-top: 10px;
margin-top: 17px;
}
.subfield-legend-group {
display: inline-flex;
align-items: center;
gap: 7px;
gap: 9px;
max-width: 100%;
min-height: 24px;
padding: 3px 8px;
min-width: 0;
min-height: 28px;
padding: 5px 9px;
border: 1px solid #dbe5f6;
border-radius: 999px;
background: #fbfdff;
@@ -87,23 +146,19 @@
.subfield-legend-field {
flex: 0 0 auto;
color: #1b2a4a;
color: #07163d;
font-size: 11px;
font-weight: 800;
line-height: 1.2;
}
.subfield-legend-items {
display: inline-flex;
flex-wrap: wrap;
align-items: center;
gap: 5px 8px;
gap: 6px 11px;
min-width: 0;
}
.subfield-legend-item {
display: inline-flex;
align-items: center;
gap: 5px;
min-width: 0;
color: #53617e;
@@ -121,19 +176,13 @@
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2);
}
.subfield-legend-toggle {
.subfield-legend-more-toggle {
flex: 0 0 auto;
min-height: 24px;
padding: 3px 8px;
border: 1px solid #bdd4ff;
border-radius: 999px;
background: #f0f6ff;
color: var(--accent);
font-size: 11px;
font-weight: 700;
&:hover {
background: #e4efff;
text-decoration: none;
}
}
@@ -447,6 +496,11 @@ app-topic-chip.timeline-topic-chip {
font-size: 12px;
}
.compact-load-more-row {
display: flex;
margin: 6px 0 28px;
}
.compact-phase-list {
display: flex;
flex-wrap: wrap;
@@ -1,4 +1,5 @@
import { CommonModule } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatTooltipModule } from '@angular/material/tooltip';
import {
@@ -91,6 +92,7 @@ interface TopicFieldLegendGroup {
standalone: true,
imports: [
CommonModule,
MatIconModule,
MatProgressSpinnerModule,
MatTooltipModule,
TopicChipComponent,
@@ -123,12 +125,13 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
maxYear = 0;
selectedStartYear = 0;
selectedEndYear = 0;
subfieldLegendVisible = true;
subfieldLegendExpanded = false;
private readonly columnWidth = 240;
private readonly displayedTopicLimit = 3;
private readonly displayedPhaseTopicLimit = 4;
private readonly collapsedSubfieldLegendLimit = 8;
private readonly collapsedSubfieldLegendGroupLimit = 3;
private readonly scrollRestoreThreshold = 24;
private readonly expandedPhaseIds = new Set<string>();
@@ -193,25 +196,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
return groups;
}
let remainingItems = this.collapsedSubfieldLegendLimit;
const visibleGroups: TopicFieldLegendGroup[] = [];
for (const group of groups) {
if (remainingItems <= 0) {
break;
}
const items = group.items.slice(0, remainingItems);
if (items.length === 0) {
continue;
}
visibleGroups.push({ ...group, items });
remainingItems -= items.length;
}
return visibleGroups;
return groups.slice(0, this.collapsedSubfieldLegendGroupLimit);
}
get hiddenSubfieldLegendItemCount(): number {
@@ -219,10 +204,9 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
return 0;
}
return Math.max(
this.allSubfieldLegendItemCount - this.collapsedSubfieldLegendLimit,
0,
);
return this.allSubfieldLegendGroups
.slice(this.collapsedSubfieldLegendGroupLimit)
.reduce((count, group) => count + group.items.length, 0);
}
get showSubfieldLegendToggle(): boolean {
@@ -461,6 +445,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
this.subfieldLegendExpanded = !this.subfieldLegendExpanded;
}
toggleSubfieldLegendVisibility(): void {
this.subfieldLegendVisible = !this.subfieldLegendVisible;
}
trackByLegendGroup(_: number, group: TopicFieldLegendGroup): string {
return group.id;
}
@@ -669,13 +657,6 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
.sort((left, right) => left.name.localeCompare(right.name));
}
private get allSubfieldLegendItemCount(): number {
return this.allSubfieldLegendGroups.reduce(
(count, group) => count + group.items.length,
0,
);
}
private get visibleLegendTopics(): TopicTimelineTopic[] {
if (this.timelineViewMode === 'compact') {
return this.compactPhases.flatMap((phase) => [