1- import { Component , HostBinding , input , InputSignal } from '@angular/core' ;
1+ import { Component , computed , input , InputSignal } from '@angular/core' ;
22import { Colors , TextColors } from '../coreui.types' ;
33import { TextBgColorDirective , TextColorDirective } from '../utilities' ;
44
@@ -10,7 +10,7 @@ import { TextBgColorDirective, TextColorDirective } from '../utilities';
1010 { directive : TextColorDirective , inputs : [ 'cTextColor: textColor' ] } ,
1111 { directive : TextBgColorDirective , inputs : [ 'cTextBgColor: textBgColor' ] }
1212 ] ,
13- host : { class : 'card' }
13+ host : { class : 'card' , '[class]' : 'hostClasses()' }
1414} )
1515export class CardComponent {
1616 /**
@@ -34,11 +34,11 @@ export class CardComponent {
3434 */
3535 readonly textBgColor : InputSignal < Colors | undefined > = input ( ) ;
3636
37- @ HostBinding ( 'class' )
38- get hostClasses ( ) : any {
37+ readonly hostClasses = computed ( ( ) => {
38+ const color = this . color ( ) ;
3939 return {
4040 card : true ,
41- [ `bg-${ this . color ( ) } ` ] : ! ! this . color ( )
42- } ;
43- }
41+ [ `bg-${ color } ` ] : ! ! color
42+ } as Record < string , boolean > ;
43+ } ) ;
4444}
0 commit comments