add legend tooltip component

This commit is contained in:
2026-08-11 09:03:54 +02:00
parent af9f9a25da
commit b0dd0e509d
5 changed files with 106 additions and 9 deletions
@@ -0,0 +1,10 @@
<div class="legend-tooltip-card">
<div class="legend-tooltip-title">{{ name() }}</div>
@if (hierarchy()) {
<div class="legend-tooltip-hierarchy">{{ hierarchy() }}</div>
}
@if (description()) {
<hr class="legend-tooltip-divider" />
<p class="legend-tooltip-description">{{ description() }}</p>
}
</div>
@@ -0,0 +1,46 @@
:host {
--topic-border: color-mix(
in srgb,
hsl(var(--topic-color)) 72%,
var(--sg-color-mix-base)
);
--topic-background: color-mix(
in srgb,
hsl(var(--topic-color)) 8%,
var(--sg-color-mix-base)
);
}
.legend-tooltip-card {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 1rem;
border-radius: var(--sg-radius-sm);
background-color: var(--topic-background);
border: 1px solid var(--topic-border);
color: var(--sg-text);
}
.legend-tooltip-title {
font-weight: 600;
font-size: 1rem;
}
.legend-tooltip-hierarchy {
color: var(--sg-text-muted);
font-size: 0.875rem;
}
.legend-tooltip-divider {
margin: 0;
border: none;
border-top: 1px solid var(--topic-border);
}
.legend-tooltip-description {
margin: 0;
color: var(--sg-text);
font-size: 0.875rem;
line-height: 1.4;
}
@@ -0,0 +1,23 @@
import { Component, computed, input } from '@angular/core';
@Component({
host: {
'[style.--topic-color]': 'topicColorVar()',
},
selector: 'app-legend-tooltip',
standalone: true,
templateUrl: './legend-tooltip.component.html',
styleUrl: './legend-tooltip.component.scss',
})
export class LegendTooltipComponent {
readonly name = input.required<string>();
readonly hierarchy = input<string | null | undefined>(null);
readonly description = input<string | null | undefined>(null);
readonly color = input<string | null | undefined>(null);
readonly topicColorVar = computed(() => {
const color = this.color();
if (!color) return '';
return color.replace('hsl(', '').replace(')', '');
});
}
@@ -54,10 +54,15 @@
class="topic-legend-field"
[class.topic-legend-entry-active]="isFieldActive(group)"
[attr.aria-pressed]="selectable ? isFieldActive(group) : null"
[matTooltip]="group.tooltip"
[matTooltipDisabled]="!group.tooltip"
matTooltipClass="topic-chip-tooltip"
matTooltipPosition="above"
[appComponentTooltip]="LegendTooltipComponent"
[tooltipInputs]="{
name: group.name,
hierarchy: group.domainName,
description: group.description,
color: group.color,
}"
[tooltipDisabled]="!group.description"
[tooltipMaxWidth]="'420px'"
(click)="toggleField(group)">
<span
class="topic-legend-dot"
@@ -73,10 +78,15 @@
class="topic-legend-item"
[class.topic-legend-entry-active]="isSubfieldActive(item)"
[attr.aria-pressed]="selectable ? isSubfieldActive(item) : null"
[matTooltip]="item.tooltip"
[matTooltipDisabled]="!item.tooltip"
matTooltipClass="topic-chip-tooltip"
matTooltipPosition="above"
[appComponentTooltip]="LegendTooltipComponent"
[tooltipInputs]="{
name: item.name,
hierarchy: group.name + ' - ' + group.domainName,
description: item.description,
color: group.color,
}"
[tooltipDisabled]="!item.description"
[tooltipMaxWidth]="'420px'"
(click)="toggleSubfield(group, item)">
{{ item.name }}
</button>
@@ -2,6 +2,8 @@ import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
import { LegendTooltipComponent } from '../legend-tooltip/legend-tooltip.component';
import {
TopicLegendGroup,
TopicLegendItem,
@@ -13,11 +15,17 @@ export type TopicLegendVariant = 'default' | 'compact';
@Component({
selector: 'app-topic-legend',
standalone: true,
imports: [CommonModule, MatIconModule, MatTooltipModule],
imports: [
CommonModule,
MatIconModule,
MatTooltipModule,
ComponentTooltipDirective,
],
templateUrl: './topic-legend.component.html',
styleUrl: './topic-legend.component.scss',
})
export class TopicLegendComponent {
readonly LegendTooltipComponent = LegendTooltipComponent;
@Input() groups: TopicLegendGroup[] = [];
@Input() title = 'Farben nach Fachgebiet';
@Input() infoTooltip =