refactored from legacy host binding to use modern @component (host: ) implementation
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
HostBinding,
|
||||
Input,
|
||||
Output,
|
||||
} from '@angular/core';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { buildTopicHierarchyTooltip } from '../../../resolvers/utils/topic-tooltip';
|
||||
@@ -75,6 +69,18 @@ export const topicChipColorTokens = (
|
||||
templateUrl: './topic-chip.component.html',
|
||||
styleUrl: './topic-chip.component.scss',
|
||||
standalone: true,
|
||||
host: {
|
||||
'[class.topic-chip--normal]': 'normalSize',
|
||||
'[class.topic-chip--mini]': 'miniSize',
|
||||
'[class.topic-chip--active]': 'activeState',
|
||||
'[style.--topic-border]': 'topicBorder',
|
||||
'[style.--topic-bg]': 'topicBackground',
|
||||
'[style.--topic-active-bg]': 'topicActiveBackground',
|
||||
'[style.--topic-color]': 'topicColor',
|
||||
'[style.--topic-text]': 'topicText',
|
||||
'[style.--topic-count-bg]': 'topicCountBackground',
|
||||
'[style.--topic-count-text]': 'topicCountText',
|
||||
},
|
||||
})
|
||||
export class TopicChipComponent {
|
||||
@Input() label = '';
|
||||
@@ -93,22 +99,18 @@ export class TopicChipComponent {
|
||||
|
||||
@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 ??
|
||||
@@ -116,7 +118,6 @@ export class TopicChipComponent {
|
||||
);
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-bg')
|
||||
get topicBackground(): string {
|
||||
return (
|
||||
this.colorTokens?.background ??
|
||||
@@ -124,7 +125,6 @@ export class TopicChipComponent {
|
||||
);
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-active-bg')
|
||||
get topicActiveBackground(): string {
|
||||
return (
|
||||
this.colorTokens?.activeBackground ??
|
||||
@@ -132,24 +132,20 @@ export class TopicChipComponent {
|
||||
);
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-color')
|
||||
get topicColor(): string {
|
||||
return this.colorTokens?.color ?? this.color;
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-text')
|
||||
get topicText(): string {
|
||||
return this.colorTokens?.color
|
||||
? this.colorTokens.color
|
||||
: `color-mix(in srgb, ${this.topicColor} 38%, var(--sg-text))`;
|
||||
: `color-mix(in srgb, ${this.topicColor} 45%, var(--sg-text))`;
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-count-bg')
|
||||
get topicCountBackground(): string {
|
||||
return this.colorTokens?.background ?? 'var(--sg-surface)';
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-count-text')
|
||||
get topicCountText(): string {
|
||||
return this.colorTokens?.color
|
||||
? this.colorTokens.color
|
||||
|
||||
Reference in New Issue
Block a user