Skip to content

Commit

Permalink
refactor(badge): host bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
xidedix committed Aug 19, 2024
1 parent cb2e68f commit 95e03c2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions projects/coreui-angular/src/lib/badge/badge.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, HostBinding, input, InputSignal } from '@angular/core';
import { Component, computed, input, InputSignal } from '@angular/core';
import { BadgePositions, Colors, Shapes, TextColors } from '../coreui.types';
import { TextBgColorDirective, TextColorDirective } from '../utilities';

Expand All @@ -11,7 +11,8 @@ import { TextBgColorDirective, TextColorDirective } from '../utilities';
{ directive: TextBgColorDirective, inputs: ['cTextBgColor: textBgColor'] }
],
host: {
class: 'badge'
class: 'badge',
'[class]': 'hostClasses()'
}
})
export class BadgeComponent {
Expand Down Expand Up @@ -52,8 +53,7 @@ export class BadgeComponent {
*/
readonly textBgColor: InputSignal<Colors | undefined> = input();

@HostBinding('class')
get hostClasses(): any {
readonly hostClasses = computed(() => {
const position = this.position();
const positionClasses = {
'position-absolute': !!position,
Expand All @@ -72,6 +72,6 @@ export class BadgeComponent {
[`${this.shape()}`]: !!this.shape()
},
!!position ? positionClasses : {}
);
}
) as Record<string, boolean>;
});
}

0 comments on commit 95e03c2

Please sign in to comment.