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' ;
3
3
4
4
import { Colors , Shapes , Sizes , TextColors } from '../coreui.types' ;
5
5
import { TextColorDirective } from '../utilities' ;
@@ -8,72 +8,73 @@ import { TextColorDirective } from '../utilities';
8
8
selector : 'c-avatar' ,
9
9
templateUrl : './avatar.component.html' ,
10
10
standalone : true ,
11
- imports : [ NgTemplateOutlet , NgClass , NgOptimizedImage ] ,
11
+ imports : [ NgClass , NgOptimizedImage ] ,
12
12
hostDirectives : [
13
13
{
14
14
directive : TextColorDirective ,
15
15
inputs : [ 'cTextColor: textColor' ]
16
16
}
17
- ]
17
+ ] ,
18
+ host : { class : 'avatar' }
18
19
} )
19
20
export class AvatarComponent {
20
21
/**
21
22
* Sets the background color context of the component to one of CoreUI’s themed colors.
22
23
* @type Colors
23
24
*/
24
- @ Input ( ) color ?: Colors ;
25
+ readonly color : InputSignal < Colors | undefined > = input ( ) ;
25
26
26
27
/**
27
28
* Select the shape of the component.
28
29
* @type Shapes
29
30
*/
30
- @ Input ( ) shape ?: Shapes ;
31
+ readonly shape : InputSignal < Shapes | undefined > = input ( ) ;
31
32
32
33
/**
33
34
* Size the component small, large, or extra large.
34
35
* @default 'md'
35
36
*/
36
- @ Input ( ) size ?: Omit < Sizes , 'xxl' > = ' md';
37
+ readonly size : InputSignal < Omit < Sizes , 'xxl' > > = input < Omit < Sizes , 'xxl' > > ( ' md') ;
37
38
38
39
/**
39
40
* The alt attribute for the img element alternate text.
40
41
* @type string
41
42
*/
42
- @ Input ( ) alt : string = '' ;
43
+ readonly alt : InputSignal < string > = input ( '' ) ;
43
44
44
45
/**
45
46
* The src attribute for the img element.
46
47
* @type string
47
48
*/
48
- @ Input ( ) src ?: string ;
49
+ readonly src : InputSignal < string | undefined > = input ( ) ;
49
50
50
51
/**
51
52
* Sets the color context of the status indicator to one of CoreUI’s themed colors.
52
53
* @type Colors
53
54
*/
54
- @ Input ( ) status ?: Colors ;
55
+ readonly status : InputSignal < Colors | undefined > = input ( ) ;
55
56
56
57
/**
57
58
* Sets the text color of the component to one of CoreUI’s themed colors.
58
59
* via TextColorDirective
59
60
* @type TextColors
60
61
*/
61
- @ Input ( ) textColor ?: TextColors ;
62
+ readonly textColor : InputSignal < TextColors | undefined > = input ( ) ;
62
63
63
- get statusClass ( ) : any {
64
+ readonly statusClass = computed ( ( ) => {
64
65
return {
65
66
'avatar-status' : true ,
66
- [ `bg-${ this . status } ` ] : ! ! this . status
67
+ [ `bg-${ this . status ( ) } ` ] : ! ! this . status ( )
67
68
} ;
68
- }
69
+ } ) ;
69
70
70
71
@HostBinding ( 'class' )
71
72
get hostClasses ( ) : any {
72
73
return {
73
74
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 ( )
77
78
} ;
78
79
}
79
80
}
0 commit comments