Fix avatar with username starting with numbers
This commit is contained in:
parent
fbd573e59c
commit
f41efa52a4
2 changed files with 5 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
<ng-template #img>
|
||||
<img *ngIf="previewImage || avatarUrl || !initial" [class]="getClass('avatar')" [src]="previewImage || avatarUrl || defaultAvatarUrl" [alt]="alt" />
|
||||
|
||||
<div *ngIf="!avatarUrl && initial" [class]="getClass('initial')">
|
||||
<div *ngIf="!avatarUrl && initial" [ngClass]="getClass('initial')">
|
||||
<span>{{ initial }}</span>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
|
|
@ -89,9 +89,11 @@ export class ActorAvatarComponent {
|
|||
}
|
||||
|
||||
private getColorTheme () {
|
||||
const initialLowercase = this.initial.toLowerCase()
|
||||
|
||||
// Keep consistency with CSS
|
||||
const themes = {
|
||||
abc: 'blue',
|
||||
'0123456789abc': 'blue',
|
||||
def: 'green',
|
||||
ghi: 'purple',
|
||||
jkl: 'gray',
|
||||
|
@ -102,7 +104,7 @@ export class ActorAvatarComponent {
|
|||
}
|
||||
|
||||
const theme = Object.keys(themes)
|
||||
.find(chars => chars.includes(this.initial))
|
||||
.find(chars => chars.includes(initialLowercase))
|
||||
|
||||
return themes[theme]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue