Skip to content

Commit cb2e68f

Browse files
committed
refactor(avatar): host bindings
1 parent abdef12 commit cb2e68f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgClass, NgOptimizedImage } from '@angular/common';
2-
import { Component, computed, HostBinding, input, InputSignal } from '@angular/core';
2+
import { Component, computed, input, InputSignal } from '@angular/core';
33

44
import { Colors, Shapes, Sizes, TextColors } from '../coreui.types';
55
import { TextColorDirective } from '../utilities';
@@ -15,7 +15,7 @@ import { TextColorDirective } from '../utilities';
1515
inputs: ['cTextColor: textColor']
1616
}
1717
],
18-
host: { class: 'avatar' }
18+
host: { class: 'avatar', '[class]': 'hostClasses()' }
1919
})
2020
export class AvatarComponent {
2121
/**
@@ -65,16 +65,15 @@ export class AvatarComponent {
6565
return {
6666
'avatar-status': true,
6767
[`bg-${this.status()}`]: !!this.status()
68-
};
68+
} as Record<string, boolean>;
6969
});
7070

71-
@HostBinding('class')
72-
get hostClasses(): any {
71+
readonly hostClasses = computed(() => {
7372
return {
7473
avatar: true,
7574
[`avatar-${this.size()}`]: !!this.size(),
7675
[`bg-${this.color()}`]: !!this.color(),
7776
[`${this.shape()}`]: !!this.shape()
78-
};
79-
}
77+
} as Record<string, boolean>;
78+
});
8079
}

0 commit comments

Comments
 (0)