diff options
Diffstat (limited to 'client/src/app/shared/shared-account-avatar/account-avatar.component.ts')
-rw-r--r-- | client/src/app/shared/shared-account-avatar/account-avatar.component.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-account-avatar/account-avatar.component.ts b/client/src/app/shared/shared-account-avatar/account-avatar.component.ts new file mode 100644 index 000000000..d5533d459 --- /dev/null +++ b/client/src/app/shared/shared-account-avatar/account-avatar.component.ts | |||
@@ -0,0 +1,38 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | import { Account as AccountInterface } from '@shared/models' | ||
3 | import { Account } from '../shared-main/account/account.model' | ||
4 | |||
5 | @Component({ | ||
6 | selector: 'my-account-avatar', | ||
7 | styleUrls: [ './account-avatar.component.scss' ], | ||
8 | templateUrl: './account-avatar.component.html' | ||
9 | }) | ||
10 | export class AccountAvatarComponent { | ||
11 | _href: string | ||
12 | _title: string | ||
13 | |||
14 | @Input() account: { name: string, avatar?: { url?: string }, url: string } | ||
15 | @Input() size = '36' | ||
16 | @Input() set href (value) { | ||
17 | this._href = value | ||
18 | } | ||
19 | @Input() set title (value) { | ||
20 | this._title = value | ||
21 | } | ||
22 | |||
23 | get href () { | ||
24 | return this._href || this.account?.url | ||
25 | } | ||
26 | |||
27 | get title () { | ||
28 | return this._title || $localize`${this.account.name} (account page)` | ||
29 | } | ||
30 | |||
31 | get class () { | ||
32 | return `avatar avatar-${this.size}` | ||
33 | } | ||
34 | |||
35 | get avatarUrl () { | ||
36 | return this.account?.avatar ? this.account.avatar.url : Account.GET_DEFAULT_AVATAR_URL() | ||
37 | } | ||
38 | } | ||