mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
[SM-251] Migrate to new avatar component (#3600)
This commit is contained in:
@@ -17,9 +17,9 @@ const SizeClasses: Record<SizeTypes, string[]> = {
|
||||
})
|
||||
export class AvatarComponent implements OnChanges {
|
||||
@Input() border = false;
|
||||
@Input() color: string;
|
||||
@Input() id: number;
|
||||
@Input() text: string;
|
||||
@Input() color?: string;
|
||||
@Input() id?: string;
|
||||
@Input() text?: string;
|
||||
@Input() size: SizeTypes = "default";
|
||||
|
||||
private svgCharCount = 2;
|
||||
@@ -42,7 +42,7 @@ export class AvatarComponent implements OnChanges {
|
||||
|
||||
private generate() {
|
||||
let chars: string = null;
|
||||
const upperCaseText = this.text.toUpperCase();
|
||||
const upperCaseText = this.text?.toUpperCase() ?? "";
|
||||
|
||||
chars = this.getFirstLetters(upperCaseText, this.svgCharCount);
|
||||
|
||||
@@ -58,9 +58,9 @@ export class AvatarComponent implements OnChanges {
|
||||
let svg: HTMLElement;
|
||||
let hexColor = this.color;
|
||||
|
||||
if (this.color != null) {
|
||||
if (!Utils.isNullOrWhitespace(this.color)) {
|
||||
svg = this.createSvgElement(this.svgSize, hexColor);
|
||||
} else if (this.id != null) {
|
||||
} else if (!Utils.isNullOrWhitespace(this.id)) {
|
||||
hexColor = Utils.stringToColor(this.id.toString());
|
||||
svg = this.createSvgElement(this.svgSize, hexColor);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user