add expandable topic color legend

This commit is contained in:
2026-06-22 23:54:23 +02:00
parent 95a9dcceff
commit 6ea5ac1b17
3 changed files with 145 additions and 36 deletions
@@ -6,28 +6,52 @@
<mat-icon class="footnote-icon">article</mat-icon>
Anzahl Publikationen zum Thema
</span>
@if (legendGroups().length > 0) {
<div class="interest-legend" aria-label="Subfields der Themen">
@for (group of legendGroups(); track group.id) {
<span class="interest-legend-group">
<span class="interest-legend-field">{{ group.name }}</span>
<span class="interest-legend-items">
@for (item of group.items; track item.id) {
<span class="interest-legend-item">
<span
class="interest-legend-dot"
[style.background]="item.color"
aria-hidden="true"></span>
<span>{{ item.name }}</span>
</span>
}
</span>
</span>
}
</div>
}
}
</div>
@if (visibleLegendGroups().length > 0) {
<div class="interest-legend" aria-label="Aktuell sichtbare Themenbereiche">
<mat-icon
class="interest-legend-info"
matTooltip="Fachgebiete geben die Farbfamilie vor, Themenbereiche bestimmen die konkrete Farbvariante."
matTooltipPosition="above"
aria-label="Informationen zur Farblegende">
info_outline
</mat-icon>
<div class="interest-legend-content">
@for (group of visibleLegendGroups(); track group.id) {
<span class="interest-legend-group">
<span class="interest-legend-field">{{ group.name }}</span>
<span class="interest-legend-items">
@for (item of group.items; track item.id) {
<span class="interest-legend-item">
<span
class="interest-legend-dot"
[style.background]="item.color"
aria-hidden="true"></span>
<span>{{ item.name }}</span>
</span>
}
</span>
</span>
}
@if (hasHiddenLegendGroups()) {
<button
type="button"
class="interest-legend-more"
[attr.aria-expanded]="legendExpanded()"
(click)="toggleLegend()">
@if (legendExpanded()) {
Weniger anzeigen
} @else {
+{{ hiddenLegendItemCount() }} weitere
}
</button>
}
</div>
</div>
}
<div class="interest-tags">
@if (tags().length > 0) {
@for (tag of tags(); track tag.label) {
@@ -15,7 +15,7 @@
align-items: baseline;
gap: 10px;
flex-wrap: wrap;
margin: 0 0 18px;
margin: 0 0 12px;
}
.interest-card h3 {
@@ -46,50 +46,87 @@
}
.interest-legend {
display: flex;
align-items: flex-start;
gap: 9px;
width: fit-content;
max-width: 100%;
margin: 0 0 16px;
padding: 8px 10px;
border: 1px solid #dbe5f6;
border-radius: 8px;
background: #ffffff;
box-sizing: border-box;
}
.interest-legend-content,
.interest-legend-group,
.interest-legend-items,
.interest-legend-item {
display: inline-flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
}
.interest-legend-info {
flex: 0 0 auto;
width: 14px;
height: 14px;
color: #7d8aa8;
font-size: 14px;
line-height: 14px;
}
.interest-legend-content {
gap: 7px;
flex: 0 1 auto;
min-width: 0;
max-width: 100%;
flex-wrap: wrap;
}
.interest-legend-group {
display: inline-flex;
align-items: center;
gap: 6px;
flex: 0 1 auto;
flex-wrap: wrap;
min-width: 0;
max-width: 100%;
min-height: 22px;
min-height: 24px;
padding: 3px 7px;
border: 1px solid #dbe5f6;
border-radius: 999px;
background: rgba(255, 255, 255, 0.68);
background: #fbfdff;
}
.interest-legend-field {
flex: 0 0 auto;
color: #1b2a4a;
flex: 0 1 auto;
min-width: 0;
color: #07163d;
font-size: 10px;
font-weight: 800;
line-height: 1.2;
}
.interest-legend-items {
display: inline-flex;
flex-wrap: wrap;
align-items: center;
flex: 0 1 auto;
gap: 4px 7px;
min-width: 0;
flex-wrap: wrap;
}
.interest-legend-item {
display: inline-flex;
align-items: center;
gap: 4px;
flex: 0 0 auto;
min-width: 0;
color: #53617e;
font-size: 10px;
font-weight: 600;
line-height: 1.2;
white-space: nowrap;
span:last-child {
overflow: visible;
text-overflow: clip;
}
}
.interest-legend-dot {
@@ -101,6 +138,32 @@
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2);
}
.interest-legend-more {
display: inline-flex;
align-items: center;
flex: 0 0 auto;
min-height: 24px;
padding: 0 2px;
border: 0;
background: transparent;
color: var(--accent, #0057ff);
cursor: pointer;
font: inherit;
font-size: 11px;
font-weight: 700;
white-space: nowrap;
&:hover {
text-decoration: underline;
}
&:focus-visible {
outline: 2px solid var(--accent, #0057ff);
outline-offset: 2px;
border-radius: 4px;
}
}
.interest-tags .interest-empty {
padding: 9px 16px;
border: 1px solid #e2e8f0;
@@ -1,5 +1,6 @@
import { Component, input, computed, output } from '@angular/core';
import { Component, input, computed, output, signal } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { CommonModule } from '@angular/common';
import { TopicCount } from '../../api';
@@ -33,15 +34,17 @@ interface InterestLegendItem {
}
const MAX_TAGS = 5;
const MAX_LEGEND_GROUPS = 3;
@Component({
selector: 'app-person-interesting',
imports: [CommonModule, MatIconModule, TopicChipComponent],
imports: [CommonModule, MatIconModule, MatTooltipModule, TopicChipComponent],
templateUrl: './person-interesting.component.html',
styleUrl: './person-interesting.component.scss',
})
export class PersonInterestingComponent {
readonly topics = input<TopicCount[] | null>(null);
readonly legendExpanded = signal(false);
readonly tagClick = output<{ id: string; name: string }>();
@@ -114,8 +117,27 @@ export class PersonInterestingComponent {
.sort((left, right) => left.name.localeCompare(right.name));
});
readonly visibleLegendGroups = computed<InterestLegendGroup[]>(() => {
const groups = this.legendGroups();
return this.legendExpanded() ? groups : groups.slice(0, MAX_LEGEND_GROUPS);
});
readonly hasHiddenLegendGroups = computed<boolean>(
() => this.legendGroups().length > MAX_LEGEND_GROUPS,
);
readonly hiddenLegendItemCount = computed<number>(() =>
this.legendGroups()
.slice(MAX_LEGEND_GROUPS)
.reduce((count, group) => count + group.items.length, 0),
);
onTagClick(tag: InterestTag): void {
if (!tag.id) return;
this.tagClick.emit({ id: tag.id, name: tag.label });
}
toggleLegend(): void {
this.legendExpanded.update((expanded) => !expanded);
}
}