Skip to content

Commit 7d1e53d

Browse files
committed
refactor(badge): update TextColors, use TextColorDirective composition
1 parent 7bdcca2 commit 7d1e53d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

projects/coreui-angular/src/lib/badge/badge.component.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { Component, HostBinding, Input } from '@angular/core';
2-
import { BadgePositions, Colors, Shapes } from '../coreui.types';
2+
import { BadgePositions, Colors, Shapes, TextColors } from '../coreui.types';
3+
import { TextColorDirective } from '../utilities';
34

45
@Component({
56
selector: 'c-badge',
67
template: '<ng-content></ng-content>',
7-
standalone: true
8+
standalone: true,
9+
hostDirectives: [{
10+
directive: TextColorDirective, inputs: ['cTextColor: textColor']
11+
}]
812
})
913
export class BadgeComponent {
1014
/**
@@ -26,11 +30,13 @@ export class BadgeComponent {
2630
* Size the component small.
2731
*/
2832
@Input() size?: 'sm';
33+
2934
/**
3035
* Sets the text color of the component to one of CoreUI’s themed colors.
36+
* via TextColorDirective
3137
* @type TextColors
3238
*/
33-
@Input() textColor?: string;
39+
@Input() textColor?: TextColors;
3440

3541
constructor() {}
3642

@@ -48,7 +54,6 @@ export class BadgeComponent {
4854
return Object.assign({
4955
badge: true,
5056
[`bg-${this.color}`]: !!this.color,
51-
[`text-${this.textColor}`]: !!this.textColor,
5257
[`badge-${this.size}`]: !!this.size,
5358
[`${this.shape}`]: !!this.shape
5459
}, !!this.position ? positionClasses : {}

0 commit comments

Comments
 (0)