Create reusable topic chip component
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -11,19 +11,16 @@
|
||||
<div class="interest-tags">
|
||||
@if (tags().length > 0) {
|
||||
@for (tag of tags(); track tag.label; let i = $index) {
|
||||
<button
|
||||
type="button"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(i)"
|
||||
[matTooltip]="tag.description"
|
||||
<app-topic-chip
|
||||
[label]="tag.label"
|
||||
[count]="tag.count"
|
||||
[description]="tag.description"
|
||||
[color]="getColorClass(i)"
|
||||
[disabled]="!tag.id"
|
||||
(click)="onTagClick(tag)">
|
||||
<span class="topic-name">{{ tag.label }}</span>
|
||||
<span class="topic-count">
|
||||
{{ tag.count }}
|
||||
<mat-icon class="count-icon">article</mat-icon>
|
||||
</span>
|
||||
</button>
|
||||
countIcon="article"
|
||||
descriptionTooltipTarget="button"
|
||||
(chipClick)="onTagClick(tag)">
|
||||
</app-topic-chip>
|
||||
}
|
||||
} @else {
|
||||
<span class="interest-empty">Keine Themen gefunden</span>
|
||||
|
||||
@@ -29,98 +29,6 @@
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.topic-chip {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
column-gap: 8px;
|
||||
box-sizing: border-box;
|
||||
min-height: 34px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--topic-border);
|
||||
border-radius: 8px;
|
||||
background: var(--topic-bg);
|
||||
color: var(--topic-color);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.25;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.topic-name {
|
||||
min-width: 0;
|
||||
text-align: center;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.topic-count {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.78);
|
||||
color: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.topic-count .count-icon {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.purple {
|
||||
--topic-border: #d8cafe;
|
||||
--topic-bg: #f6f0ff;
|
||||
--topic-color: #7255d9;
|
||||
}
|
||||
|
||||
.blue {
|
||||
--topic-border: #bdd4ff;
|
||||
--topic-bg: #f0f6ff;
|
||||
--topic-color: #0b63ce;
|
||||
}
|
||||
|
||||
.green {
|
||||
--topic-border: #bdebcf;
|
||||
--topic-bg: #effaf3;
|
||||
--topic-color: #24834f;
|
||||
}
|
||||
|
||||
.orange {
|
||||
--topic-border: #ffd796;
|
||||
--topic-bg: #fff7e8;
|
||||
--topic-color: #c67500;
|
||||
}
|
||||
|
||||
.pink {
|
||||
--topic-border: #ffc7d7;
|
||||
--topic-bg: #fff1f5;
|
||||
--topic-color: #d12f61;
|
||||
}
|
||||
|
||||
.interest-footnote {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { Component, input, computed, output } from '@angular/core';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { TopicCount } from '../../api';
|
||||
import {
|
||||
TOPIC_CHIP_PALETTE,
|
||||
TopicChipComponent,
|
||||
} from '../../shared/ui/topic-chip/topic-chip.component';
|
||||
|
||||
interface InterestTag {
|
||||
id: string;
|
||||
@@ -13,11 +16,10 @@ interface InterestTag {
|
||||
}
|
||||
|
||||
const MAX_TAGS = 5;
|
||||
const colors = ['purple', 'blue', 'green', 'orange', 'pink'];
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-interesting',
|
||||
imports: [CommonModule, MatTooltipModule, MatIconModule],
|
||||
imports: [CommonModule, MatIconModule, TopicChipComponent],
|
||||
templateUrl: './person-interesting.component.html',
|
||||
styleUrl: './person-interesting.component.scss',
|
||||
})
|
||||
@@ -46,7 +48,7 @@ export class PersonInterestingComponent {
|
||||
});
|
||||
|
||||
getColorClass(index: number): string {
|
||||
return colors[index % colors.length];
|
||||
return TOPIC_CHIP_PALETTE[index % TOPIC_CHIP_PALETTE.length];
|
||||
}
|
||||
|
||||
onTagClick(tag: InterestTag): void {
|
||||
|
||||
+26
-48
@@ -248,28 +248,20 @@
|
||||
getDisplayedTopics(item).length > 0;
|
||||
else noTopicsForYear
|
||||
">
|
||||
<button
|
||||
type="button"
|
||||
<app-topic-chip
|
||||
*ngFor="
|
||||
let topic of getDisplayedTopics(item);
|
||||
trackBy: trackByTopic
|
||||
"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
class="timeline-topic-chip"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
[countTooltip]="getYearTopicCountTooltip(topic, item)"
|
||||
[color]="getColorClass(index)"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic, [item.year])">
|
||||
<span
|
||||
class="topic-name"
|
||||
[matTooltip]="getTopicDescription(topic)"
|
||||
[matTooltipDisabled]="!hasTopicDescription(topic)">
|
||||
{{ topic.name }}
|
||||
</span>
|
||||
<span
|
||||
class="topic-count"
|
||||
[matTooltip]="getYearTopicCountTooltip(topic, item)">
|
||||
{{ topic.count }}
|
||||
</span>
|
||||
</button>
|
||||
(chipClick)="selectTopic(topic, [item.year])">
|
||||
</app-topic-chip>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noTopicsForYear>
|
||||
@@ -344,25 +336,17 @@
|
||||
<div class="phase-topics">
|
||||
<ng-container
|
||||
*ngIf="phase.topics.length > 0; else noPhaseTopics">
|
||||
<button
|
||||
type="button"
|
||||
<app-topic-chip
|
||||
*ngFor="let topic of phase.topics; trackBy: trackByTopic"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
class="phase-topic-chip"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
[countTooltip]="getPhaseTopicCountTooltip(topic, phase)"
|
||||
[color]="getColorClass(index)"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic, getPhaseYears(phase))">
|
||||
<span
|
||||
class="topic-name"
|
||||
[matTooltip]="getTopicDescription(topic)"
|
||||
[matTooltipDisabled]="!hasTopicDescription(topic)">
|
||||
{{ topic.name }}
|
||||
</span>
|
||||
<span
|
||||
class="topic-count"
|
||||
[matTooltip]="getPhaseTopicCountTooltip(topic, phase)">
|
||||
{{ topic.count }}
|
||||
</span>
|
||||
</button>
|
||||
(chipClick)="selectTopic(topic, getPhaseYears(phase))">
|
||||
</app-topic-chip>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noPhaseTopics>
|
||||
@@ -420,8 +404,7 @@
|
||||
).length > 0;
|
||||
else noPhaseYearTopics
|
||||
">
|
||||
<button
|
||||
type="button"
|
||||
<app-topic-chip
|
||||
*ngFor="
|
||||
let topic of getDisplayedTopicsForPrimaryTopic(
|
||||
year,
|
||||
@@ -429,19 +412,14 @@
|
||||
);
|
||||
trackBy: trackByTopic
|
||||
"
|
||||
class="mini-topic-chip"
|
||||
size="mini"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
[countTooltip]="getYearTopicCountTooltip(topic, year)"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic, [year.year])">
|
||||
<span
|
||||
[matTooltip]="getTopicDescription(topic)"
|
||||
[matTooltipDisabled]="!hasTopicDescription(topic)">
|
||||
{{ topic.name }}
|
||||
</span>
|
||||
<strong
|
||||
[matTooltip]="getYearTopicCountTooltip(topic, year)">
|
||||
{{ topic.count }}
|
||||
</strong>
|
||||
</button>
|
||||
(chipClick)="selectTopic(topic, [year.year])">
|
||||
</app-topic-chip>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noPhaseYearTopics>
|
||||
|
||||
+2
-105
@@ -11,9 +11,6 @@
|
||||
|
||||
button {
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
button:not(:where(.topic-chip, .mini-topic-chip)) {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
@@ -366,60 +363,9 @@
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.topic-chip {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
column-gap: 8px;
|
||||
app-topic-chip.timeline-topic-chip {
|
||||
width: 100%;
|
||||
max-width: 210px;
|
||||
box-sizing: border-box;
|
||||
min-height: 34px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid var(--topic-border);
|
||||
border-radius: 8px;
|
||||
background: var(--topic-bg);
|
||||
color: var(--topic-color);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.25;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.topic-name,
|
||||
.mini-topic-chip span {
|
||||
min-width: 0;
|
||||
text-align: center;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.topic-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.78);
|
||||
color: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.no-topics {
|
||||
@@ -505,7 +451,7 @@
|
||||
gap: 7px;
|
||||
margin-top: 14px;
|
||||
|
||||
.topic-chip {
|
||||
app-topic-chip.phase-topic-chip {
|
||||
flex: 0 0 calc((100% - 7px) / 2);
|
||||
width: calc((100% - 7px) / 2);
|
||||
max-width: none;
|
||||
@@ -574,73 +520,24 @@
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.mini-topic-chip {
|
||||
display: inline-grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
column-gap: 5px;
|
||||
max-width: 100%;
|
||||
padding: 4px 7px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
background: #f2f6ff;
|
||||
color: #40506f;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.25;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
strong {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
color: var(--accent);
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.purple {
|
||||
--timeline-color: #7255d9;
|
||||
--topic-border: #d8cafe;
|
||||
--topic-bg: #f6f0ff;
|
||||
--topic-color: #7255d9;
|
||||
}
|
||||
|
||||
.blue {
|
||||
--timeline-color: #2678e8;
|
||||
--topic-border: #bdd4ff;
|
||||
--topic-bg: #f0f6ff;
|
||||
--topic-color: #0b63ce;
|
||||
}
|
||||
|
||||
.green {
|
||||
--timeline-color: #39a96b;
|
||||
--topic-border: #bdebcf;
|
||||
--topic-bg: #effaf3;
|
||||
--topic-color: #24834f;
|
||||
}
|
||||
|
||||
.orange {
|
||||
--timeline-color: #f59e0b;
|
||||
--topic-border: #ffd796;
|
||||
--topic-bg: #fff7e8;
|
||||
--topic-color: #c67500;
|
||||
}
|
||||
|
||||
.pink {
|
||||
--timeline-color: #e0527c;
|
||||
--topic-border: #ffc7d7;
|
||||
--topic-bg: #fff1f5;
|
||||
--topic-color: #d12f61;
|
||||
}
|
||||
|
||||
.timeline-note {
|
||||
|
||||
+11
-2
@@ -12,6 +12,10 @@ import {
|
||||
SimpleChanges,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
TOPIC_CHIP_PALETTE,
|
||||
TopicChipComponent,
|
||||
} from '../../../../shared/ui/topic-chip/topic-chip.component';
|
||||
|
||||
export interface TopicTimelineTopic {
|
||||
id?: string;
|
||||
@@ -68,7 +72,12 @@ interface TimelineScrollAnchor {
|
||||
@Component({
|
||||
selector: 'app-research-timeline',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatProgressSpinnerModule, MatTooltipModule],
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatTooltipModule,
|
||||
TopicChipComponent,
|
||||
],
|
||||
templateUrl: './research-timeline.component.html',
|
||||
styleUrl: './research-timeline.component.scss',
|
||||
})
|
||||
@@ -98,7 +107,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
selectedStartYear = 0;
|
||||
selectedEndYear = 0;
|
||||
|
||||
private readonly colors = ['purple', 'blue', 'green', 'orange', 'pink'];
|
||||
private readonly colors = TOPIC_CHIP_PALETTE;
|
||||
private readonly columnWidth = 240;
|
||||
private readonly displayedTopicLimit = 3;
|
||||
private readonly displayedPhaseTopicLimit = 4;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<button
|
||||
type="button"
|
||||
class="topic-chip__button"
|
||||
[disabled]="disabled"
|
||||
[attr.aria-pressed]="active ? 'true' : null"
|
||||
[matTooltip]="buttonTooltip"
|
||||
[matTooltipDisabled]="!buttonTooltip"
|
||||
(click)="handleClick()">
|
||||
<span
|
||||
class="topic-chip__label"
|
||||
[matTooltip]="labelTooltip"
|
||||
[matTooltipDisabled]="!labelTooltip">
|
||||
{{ label }}
|
||||
</span>
|
||||
|
||||
@if (hasCount) {
|
||||
<span
|
||||
class="topic-chip__count"
|
||||
[matTooltip]="normalizedCountTooltip"
|
||||
[matTooltipDisabled]="!normalizedCountTooltip">
|
||||
{{ count }}
|
||||
@if (countIconName) {
|
||||
<mat-icon class="topic-chip__count-icon">{{ countIconName }}</mat-icon>
|
||||
}
|
||||
</span>
|
||||
}
|
||||
</button>
|
||||
@@ -0,0 +1,108 @@
|
||||
:host {
|
||||
display: inline-flex;
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.topic-chip__button {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
color: inherit;
|
||||
font-family: inherit;
|
||||
line-height: 1.25;
|
||||
cursor: pointer;
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
:host(.topic-chip--normal) .topic-chip__button {
|
||||
column-gap: 8px;
|
||||
min-height: 34px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid var(--topic-border);
|
||||
border-radius: 8px;
|
||||
background: var(--topic-bg);
|
||||
color: var(--topic-color);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
:host(.topic-chip--mini) .topic-chip__button {
|
||||
column-gap: 5px;
|
||||
padding: 4px 7px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
background: #f2f6ff;
|
||||
color: #40506f;
|
||||
font-size: 11px;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
:host(.topic-chip--active.topic-chip--normal) .topic-chip__button {
|
||||
border-color: var(--topic-color);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--topic-color) 18%, transparent);
|
||||
}
|
||||
|
||||
:host(.topic-chip--active.topic-chip--mini) .topic-chip__button {
|
||||
background: #eaf1ff;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.topic-chip__label {
|
||||
min-width: 0;
|
||||
text-align: center;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.topic-chip__count {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.78);
|
||||
color: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
:host(.topic-chip--mini) .topic-chip__count {
|
||||
min-width: 0;
|
||||
height: auto;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--accent);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.topic-chip__count-icon {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
HostBinding,
|
||||
Input,
|
||||
Output,
|
||||
} from '@angular/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
|
||||
export const TOPIC_CHIP_PALETTE = [
|
||||
'purple',
|
||||
'blue',
|
||||
'green',
|
||||
'orange',
|
||||
'pink',
|
||||
] as const;
|
||||
|
||||
export type TopicChipPaletteColor = (typeof TOPIC_CHIP_PALETTE)[number];
|
||||
export type TopicChipColor = TopicChipPaletteColor | string;
|
||||
export type TopicChipSize = 'normal' | 'mini';
|
||||
export type TopicChipTooltipTarget = 'label' | 'button';
|
||||
|
||||
interface TopicChipColorTokens {
|
||||
border: string;
|
||||
background: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
const TOPIC_CHIP_COLORS: Record<TopicChipPaletteColor, TopicChipColorTokens> = {
|
||||
purple: {
|
||||
border: '#d8cafe',
|
||||
background: '#f6f0ff',
|
||||
color: '#7255d9',
|
||||
},
|
||||
blue: {
|
||||
border: '#bdd4ff',
|
||||
background: '#f0f6ff',
|
||||
color: '#0b63ce',
|
||||
},
|
||||
green: {
|
||||
border: '#bdebcf',
|
||||
background: '#effaf3',
|
||||
color: '#24834f',
|
||||
},
|
||||
orange: {
|
||||
border: '#ffd796',
|
||||
background: '#fff7e8',
|
||||
color: '#c67500',
|
||||
},
|
||||
pink: {
|
||||
border: '#ffc7d7',
|
||||
background: '#fff1f5',
|
||||
color: '#d12f61',
|
||||
},
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-topic-chip',
|
||||
imports: [MatIconModule, MatTooltipModule],
|
||||
templateUrl: './topic-chip.component.html',
|
||||
styleUrl: './topic-chip.component.scss',
|
||||
standalone: true,
|
||||
})
|
||||
export class TopicChipComponent {
|
||||
@Input() label = '';
|
||||
@Input() count: number | string | null | undefined;
|
||||
@Input() description: string | null | undefined = '';
|
||||
@Input() countTooltip: string | null | undefined = '';
|
||||
@Input() countIcon: string | null | undefined;
|
||||
@Input() color: TopicChipColor = 'purple';
|
||||
@Input() size: TopicChipSize = 'normal';
|
||||
@Input() disabled = false;
|
||||
@Input() active = false;
|
||||
@Input() descriptionTooltipTarget: TopicChipTooltipTarget = 'label';
|
||||
|
||||
@Output() chipClick = new EventEmitter<void>();
|
||||
|
||||
@HostBinding('class.topic-chip--normal')
|
||||
get normalSize(): boolean {
|
||||
return this.size === 'normal';
|
||||
}
|
||||
|
||||
@HostBinding('class.topic-chip--mini')
|
||||
get miniSize(): boolean {
|
||||
return this.size === 'mini';
|
||||
}
|
||||
|
||||
@HostBinding('class.topic-chip--active')
|
||||
get activeState(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-border')
|
||||
get topicBorder(): string {
|
||||
return (
|
||||
this.colorTokens?.border ??
|
||||
`color-mix(in srgb, ${this.topicColor} 35%, #ffffff)`
|
||||
);
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-bg')
|
||||
get topicBackground(): string {
|
||||
return (
|
||||
this.colorTokens?.background ??
|
||||
`color-mix(in srgb, ${this.topicColor} 10%, #ffffff)`
|
||||
);
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-color')
|
||||
get topicColor(): string {
|
||||
return this.colorTokens?.color ?? this.color;
|
||||
}
|
||||
|
||||
get hasCount(): boolean {
|
||||
return (
|
||||
this.count !== undefined && this.count !== null && `${this.count}` !== ''
|
||||
);
|
||||
}
|
||||
|
||||
get labelTooltip(): string {
|
||||
return this.descriptionTooltipTarget === 'label'
|
||||
? this.normalizedDescription
|
||||
: '';
|
||||
}
|
||||
|
||||
get buttonTooltip(): string {
|
||||
return this.descriptionTooltipTarget === 'button'
|
||||
? this.normalizedDescription
|
||||
: '';
|
||||
}
|
||||
|
||||
get normalizedCountTooltip(): string {
|
||||
return (this.countTooltip ?? '').trim();
|
||||
}
|
||||
|
||||
get countIconName(): string {
|
||||
return (this.countIcon ?? '').trim();
|
||||
}
|
||||
|
||||
handleClick(): void {
|
||||
if (this.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.chipClick.emit();
|
||||
}
|
||||
|
||||
private get normalizedDescription(): string {
|
||||
return (this.description ?? '').trim();
|
||||
}
|
||||
|
||||
private get colorTokens(): TopicChipColorTokens | undefined {
|
||||
return TOPIC_CHIP_COLORS[this.color as TopicChipPaletteColor];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user