mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
|
import { picasso } from '@app/framework/internal';
|
|
|
|
@Component({
|
|
selector: 'sqx-avatar',
|
|
styleUrls: ['./avatar.component.scss'],
|
|
templateUrl: './avatar.component.html',
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export class AvatarComponent implements OnChanges {
|
|
@Input()
|
|
public identifier: string | undefined | null;
|
|
|
|
@Input()
|
|
public image: string | undefined | null;
|
|
|
|
@Input()
|
|
public size = 50;
|
|
|
|
public imageSource: string | null;
|
|
public imageSize = '50px';
|
|
|
|
public ngOnChanges(changes: SimpleChanges) {
|
|
if (changes['image'] || changes['identifier']) {
|
|
this.imageSource = this.image || this.createSvg();
|
|
}
|
|
|
|
if (changes['size']) {
|
|
this.imageSize = `${this.size}px`;
|
|
}
|
|
}
|
|
|
|
private createSvg() {
|
|
if (this.identifier) {
|
|
return `data:image/svg+xml;utf8,${picasso(this.identifier)}`;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|