Skip to content

Commit 0bf03f8

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

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

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

55
@Component({
66
selector: 'c-badge',
7-
template: '<ng-content></ng-content>',
7+
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 BadgeComponent {
1415
/**
@@ -38,7 +39,13 @@ export class BadgeComponent {
3839
*/
3940
@Input() textColor?: TextColors;
4041

41-
constructor() {}
42+
/**
43+
* 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.
44+
* via TextBgColorDirective
45+
* @type Colors
46+
* @since 5.0.0
47+
*/
48+
@Input() textBgColor?: Colors;
4249

4350
@HostBinding('class')
4451
get hostClasses(): any {

0 commit comments

Comments
 (0)