Skip to content

Commit 15cafa3

Browse files
committed
refactor(card): use TextColorDirective composition
1 parent 0fd4283 commit 15cafa3

File tree

1 file changed

+9
-7
lines changed

1 file changed

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

45
@Component({
56
selector: 'c-card, [c-card]',
6-
template: `<ng-content></ng-content>`,
7-
standalone: true
7+
template: '<ng-content />',
8+
standalone: true,
9+
hostDirectives: [{
10+
directive: TextColorDirective, inputs: ['cTextColor: textColor']
11+
}]
812
})
913
export class CardComponent {
1014

@@ -13,8 +17,10 @@ export class CardComponent {
1317
* @type Colors
1418
*/
1519
@Input() color?: Colors;
20+
1621
/**
1722
* Sets the text color context of the component to one of CoreUI’s themed colors.
23+
* via TextColorDirective
1824
* @type TextColors
1925
*/
2026
@Input() textColor?: TextColors;
@@ -23,11 +29,7 @@ export class CardComponent {
2329
get hostClasses(): any {
2430
return {
2531
card: true,
26-
[`bg-${this.color}`]: !!this.color,
27-
[`text-${this.textColor}`]: !!this.textColor,
32+
[`bg-${this.color}`]: !!this.color
2833
};
2934
}
30-
31-
constructor() { }
32-
3335
}

0 commit comments

Comments
 (0)