mirror of
https://github.com/bitwarden/browser
synced 2025-12-24 12:13:39 +00:00
* rename file, move, and update imports * refactor and implement StateProvider * remove comments * add migration * use 'disk-local' for web * add JSDoc comments * move AvatarService before SyncService * create factory * replace old method with observable in story * fix tests * add tests for migration * receive most recent avatarColor emission * move logic to component * fix CLI dependency * remove BehaviorSubject * cleanup * use UserKeyDefinition * avoid extra write * convert to observable * fix tests
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { Component, Input, OnDestroy } from "@angular/core";
|
|
import { Subject } from "rxjs";
|
|
|
|
import { AvatarService } from "@bitwarden/common/auth/abstractions/avatar.service";
|
|
|
|
import { SharedModule } from "../shared";
|
|
|
|
type SizeTypes = "xlarge" | "large" | "default" | "small" | "xsmall";
|
|
@Component({
|
|
selector: "dynamic-avatar",
|
|
standalone: true,
|
|
imports: [SharedModule],
|
|
template: `<span [title]="title">
|
|
<bit-avatar
|
|
appStopClick
|
|
[text]="text"
|
|
[size]="size"
|
|
[color]="color$ | async"
|
|
[border]="border"
|
|
[id]="id"
|
|
[title]="title"
|
|
>
|
|
</bit-avatar>
|
|
</span>`,
|
|
})
|
|
export class DynamicAvatarComponent implements OnDestroy {
|
|
@Input() border = false;
|
|
@Input() id: string;
|
|
@Input() text: string;
|
|
@Input() title: string;
|
|
@Input() size: SizeTypes = "default";
|
|
private destroy$ = new Subject<void>();
|
|
|
|
color$ = this.avatarService.avatarColor$;
|
|
|
|
constructor(private avatarService: AvatarService) {
|
|
if (this.text) {
|
|
this.text = this.text.toUpperCase();
|
|
}
|
|
}
|
|
|
|
async ngOnDestroy() {
|
|
this.destroy$.next();
|
|
this.destroy$.complete();
|
|
}
|
|
}
|