Skip to content

Commit da5f2b6

Browse files
committed
refactor(avatar): update TextColors, use TextColorDirective composition, use control flow
1 parent b3f7fbb commit da5f2b6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ng-container>
2-
<ng-container *ngTemplateOutlet="defaultImageTemplate" />
2+
<ng-container *ngTemplateOutlet="defaultImageTemplate"></ng-container>
33
@if (!!status) {
44
<span [ngClass]="statusClass"></span>
55
}
@@ -9,6 +9,9 @@
99
@if (!!src) {
1010
<img [src]="src" class="avatar-img" />
1111
} @else {
12-
<ng-content />
12+
<ng-content></ng-content>
1313
}
14+
<ng-template #imageContent>
15+
<ng-content></ng-content>
16+
</ng-template>
1417
</ng-template>

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, HostBinding, Input } from '@angular/core';
22
import { NgClass, NgTemplateOutlet } from '@angular/common';
33

44
import { Colors, Shapes, Sizes, TextColors } from '../coreui.types';
5+
import { TextColorDirective } from '../utilities';
56

67
@Component({
78
selector: 'c-avatar',
@@ -10,7 +11,10 @@ import { Colors, Shapes, Sizes, TextColors } from '../coreui.types';
1011
imports: [
1112
NgTemplateOutlet,
1213
NgClass
13-
]
14+
],
15+
hostDirectives: [{
16+
directive: TextColorDirective, inputs: ['cTextColor: textColor']
17+
}]
1418
})
1519
export class AvatarComponent {
1620
/**
@@ -38,10 +42,11 @@ export class AvatarComponent {
3842
* @type Colors
3943
*/
4044
@Input() status?: Colors;
45+
4146
/**
4247
* Sets the text color of the component to one of CoreUI’s themed colors.
43-
*
44-
* @values 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'white' | 'muted' | string
48+
* via TextColorDirective
49+
* @type TextColors
4550
*/
4651
@Input() textColor?: TextColors;
4752

@@ -60,8 +65,7 @@ export class AvatarComponent {
6065
avatar: true,
6166
[`avatar-${this.size}`]: !!this.size,
6267
[`bg-${this.color}`]: !!this.color,
63-
[`${this.shape}`]: !!this.shape,
64-
[`text-${this.textColor}`]: !!this.textColor
68+
[`${this.shape}`]: !!this.shape
6569
};
6670
}
6771
}

0 commit comments

Comments
 (0)