1- import { Component , HostBinding , Input } from '@angular/core' ;
2- import { NgClass , NgOptimizedImage , NgTemplateOutlet } from '@angular/common' ;
1+ import { Component , computed , HostBinding , input , InputSignal } from '@angular/core' ;
2+ import { NgClass , NgOptimizedImage } from '@angular/common' ;
33
44import { Colors , Shapes , Sizes , TextColors } from '../coreui.types' ;
55import { TextColorDirective } from '../utilities' ;
@@ -8,72 +8,73 @@ import { TextColorDirective } from '../utilities';
88 selector : 'c-avatar' ,
99 templateUrl : './avatar.component.html' ,
1010 standalone : true ,
11- imports : [ NgTemplateOutlet , NgClass , NgOptimizedImage ] ,
11+ imports : [ NgClass , NgOptimizedImage ] ,
1212 hostDirectives : [
1313 {
1414 directive : TextColorDirective ,
1515 inputs : [ 'cTextColor: textColor' ]
1616 }
17- ]
17+ ] ,
18+ host : { class : 'avatar' }
1819} )
1920export class AvatarComponent {
2021 /**
2122 * Sets the background color context of the component to one of CoreUI’s themed colors.
2223 * @type Colors
2324 */
24- @ Input ( ) color ?: Colors ;
25+ readonly color : InputSignal < Colors | undefined > = input ( ) ;
2526
2627 /**
2728 * Select the shape of the component.
2829 * @type Shapes
2930 */
30- @ Input ( ) shape ?: Shapes ;
31+ readonly shape : InputSignal < Shapes | undefined > = input ( ) ;
3132
3233 /**
3334 * Size the component small, large, or extra large.
3435 * @default 'md'
3536 */
36- @ Input ( ) size ?: Omit < Sizes , 'xxl' > = ' md';
37+ readonly size : InputSignal < Omit < Sizes , 'xxl' > > = input < Omit < Sizes , 'xxl' > > ( ' md') ;
3738
3839 /**
3940 * The alt attribute for the img element alternate text.
4041 * @type string
4142 */
42- @ Input ( ) alt : string = '' ;
43+ readonly alt : InputSignal < string > = input ( '' ) ;
4344
4445 /**
4546 * The src attribute for the img element.
4647 * @type string
4748 */
48- @ Input ( ) src ?: string ;
49+ readonly src : InputSignal < string | undefined > = input ( ) ;
4950
5051 /**
5152 * Sets the color context of the status indicator to one of CoreUI’s themed colors.
5253 * @type Colors
5354 */
54- @ Input ( ) status ?: Colors ;
55+ readonly status : InputSignal < Colors | undefined > = input ( ) ;
5556
5657 /**
5758 * Sets the text color of the component to one of CoreUI’s themed colors.
5859 * via TextColorDirective
5960 * @type TextColors
6061 */
61- @ Input ( ) textColor ?: TextColors ;
62+ readonly textColor : InputSignal < TextColors | undefined > = input ( ) ;
6263
63- get statusClass ( ) : any {
64+ readonly statusClass = computed ( ( ) => {
6465 return {
6566 'avatar-status' : true ,
66- [ `bg-${ this . status } ` ] : ! ! this . status
67+ [ `bg-${ this . status ( ) } ` ] : ! ! this . status ( )
6768 } ;
68- }
69+ } ) ;
6970
7071 @HostBinding ( 'class' )
7172 get hostClasses ( ) : any {
7273 return {
7374 avatar : true ,
74- [ `avatar-${ this . size } ` ] : ! ! this . size ,
75- [ `bg-${ this . color } ` ] : ! ! this . color ,
76- [ `${ this . shape } ` ] : ! ! this . shape
75+ [ `avatar-${ this . size ( ) } ` ] : ! ! this . size ( ) ,
76+ [ `bg-${ this . color ( ) } ` ] : ! ! this . color ( ) ,
77+ [ `${ this . shape ( ) } ` ] : ! ! this . shape ( )
7778 } ;
7879 }
7980}
0 commit comments