aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-account-avatar/account-avatar.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-28 11:49:34 +0200
committerChocobozzz <me@florianbigard.com>2021-04-28 11:49:34 +0200
commit746018f6b81b40e8858303662ac9ec5ce59ac6eb (patch)
tree7b115d12c1926e6283346072fe1c6adbf056abd7 /client/src/app/shared/shared-account-avatar/account-avatar.component.ts
parentec489ce2f74570f94dffb62266f4ed6f18621b3e (diff)
downloadPeerTube-746018f6b81b40e8858303662ac9ec5ce59ac6eb.tar.gz
PeerTube-746018f6b81b40e8858303662ac9ec5ce59ac6eb.tar.zst
PeerTube-746018f6b81b40e8858303662ac9ec5ce59ac6eb.zip
Refactor actor avatar display
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.ts62
1 files changed, 0 insertions, 62 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
deleted file mode 100644
index 76b696566..000000000
--- a/client/src/app/shared/shared-account-avatar/account-avatar.component.ts
+++ /dev/null
@@ -1,62 +0,0 @@
1import { Component, Input } from '@angular/core'
2import { Account } from '../shared-main/account/account.model'
3
4@Component({
5 selector: 'my-account-avatar',
6 styleUrls: [ './account-avatar.component.scss' ],
7 templateUrl: './account-avatar.component.html'
8})
9export class AccountAvatarComponent {
10 @Input() account: {
11 name: string
12 avatar?: { url?: string, path: string }
13 url: string
14 }
15 @Input() size: '25' | '32' | '34' | '36' | '40' | '120' = '36'
16
17 // Use an external link
18 @Input() href: string
19 // Use routerLink
20 @Input() internalHref: string | string[]
21
22 @Input() set title (value) {
23 this._title = value
24 }
25
26 defaultAvatarUrl = Account.GET_DEFAULT_AVATAR_URL()
27
28 private _title: string
29
30 get title () {
31 return this._title || $localize`${this.account.name} (account page)`
32 }
33
34 get class () {
35 return `avatar avatar-${this.size}` + (this.avatarUrl ? '' : ` initial ${this.getColorTheme()}`)
36 }
37
38 get avatarUrl () {
39 return Account.GET_ACTOR_AVATAR_URL(this.account)
40 }
41
42 get initial () {
43 return this.account?.name.slice(0, 1)
44 }
45
46 private getColorTheme () {
47 const themes = {
48 abc: 'blue',
49 def: 'green',
50 ghi: 'purple',
51 jkl: 'gray',
52 mno: 'yellow',
53 pqr: 'orange',
54 stv: 'red',
55 wxyz: 'dark-blue'
56 }
57
58 const theme = Object.keys(themes).find(chars => chars.includes(this.initial))
59
60 return themes[theme]
61 }
62}