Skip to content

Commit 371cec8

Browse files
committed
refactor(card): improve background and text color handling with TextBgColor directive composition api
1 parent 0bf03f8 commit 371cec8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { Component, HostBinding, Input } from '@angular/core';
22
import { Colors, TextColors } from '../coreui.types';
3-
import { TextColorDirective } from '../utilities';
3+
import { TextBgColorDirective, TextColorDirective } from '../utilities';
44

55
@Component({
66
selector: 'c-card, [c-card]',
77
template: '<ng-content />',
88
standalone: true,
9-
hostDirectives: [{
10-
directive: TextColorDirective, inputs: ['cTextColor: textColor']
11-
}]
9+
hostDirectives: [
10+
{ directive: TextColorDirective, inputs: ['cTextColor: textColor'] },
11+
{ directive: TextBgColorDirective, inputs: ['cTextBgColor: textBgColor'] }
12+
]
1213
})
1314
export class CardComponent {
1415

@@ -25,6 +26,14 @@ export class CardComponent {
2526
*/
2627
@Input() textColor?: TextColors;
2728

29+
/**
30+
* Sets the component's color scheme to one of CoreUI's themed colors, ensuring the text color contrast adheres to the WCAG 4.5:1 contrast ratio standard for accessibility.
31+
* via TextBgColorDirective
32+
* @type Colors
33+
* @since 5.0.0
34+
*/
35+
@Input() textBgColor?: Colors;
36+
2837
@HostBinding('class')
2938
get hostClasses(): any {
3039
return {

0 commit comments

Comments
 (0)