aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-account-avatar/account-avatar.component.ts
blob: d5533d45992edf8669598a08e20a6116093b1731 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Component, Input } from '@angular/core'
import { Account as AccountInterface } from '@shared/models'
import { Account } from '../shared-main/account/account.model'

@Component({
  selector: 'my-account-avatar',
  styleUrls: [ './account-avatar.component.scss' ],
  templateUrl: './account-avatar.component.html'
})
export class AccountAvatarComponent {
  _href: string
  _title: string

  @Input() account: { name: string, avatar?: { url?: string }, url: string }
  @Input() size = '36'
  @Input() set href (value) {
    this._href = value
  }
  @Input() set title (value) {
    this._title = value
  }

  get href () {
    return this._href || this.account?.url
  }

  get title () {
    return this._title || $localize`${this.account.name} (account page)`
  }

  get class () {
    return `avatar avatar-${this.size}`
  }

  get avatarUrl () {
    return this.account?.avatar ? this.account.avatar.url : Account.GET_DEFAULT_AVATAR_URL()
  }
}