Skip to content

Commit 95e03c2

Browse files
committedAug 19, 2024
refactor(badge): host bindings
1 parent cb2e68f commit 95e03c2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

Diff for: ‎projects/coreui-angular/src/lib/badge/badge.component.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, HostBinding, input, InputSignal } from '@angular/core';
1+
import { Component, computed, input, InputSignal } from '@angular/core';
22
import { BadgePositions, Colors, Shapes, TextColors } from '../coreui.types';
33
import { TextBgColorDirective, TextColorDirective } from '../utilities';
44

@@ -11,7 +11,8 @@ import { TextBgColorDirective, TextColorDirective } from '../utilities';
1111
{ directive: TextBgColorDirective, inputs: ['cTextBgColor: textBgColor'] }
1212
],
1313
host: {
14-
class: 'badge'
14+
class: 'badge',
15+
'[class]': 'hostClasses()'
1516
}
1617
})
1718
export class BadgeComponent {
@@ -52,8 +53,7 @@ export class BadgeComponent {
5253
*/
5354
readonly textBgColor: InputSignal<Colors | undefined> = input();
5455

55-
@HostBinding('class')
56-
get hostClasses(): any {
56+
readonly hostClasses = computed(() => {
5757
const position = this.position();
5858
const positionClasses = {
5959
'position-absolute': !!position,
@@ -72,6 +72,6 @@ export class BadgeComponent {
7272
[`${this.shape()}`]: !!this.shape()
7373
},
7474
!!position ? positionClasses : {}
75-
);
76-
}
75+
) as Record<string, boolean>;
76+
});
7777
}

0 commit comments

Comments
 (0)
Please sign in to comment.