diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-28 11:49:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-04-28 11:49:34 +0200 |
commit | 746018f6b81b40e8858303662ac9ec5ce59ac6eb (patch) | |
tree | 7b115d12c1926e6283346072fe1c6adbf056abd7 /client/src/app/shared/shared-account-avatar | |
parent | ec489ce2f74570f94dffb62266f4ed6f18621b3e (diff) | |
download | PeerTube-746018f6b81b40e8858303662ac9ec5ce59ac6eb.tar.gz PeerTube-746018f6b81b40e8858303662ac9ec5ce59ac6eb.tar.zst PeerTube-746018f6b81b40e8858303662ac9ec5ce59ac6eb.zip |
Refactor actor avatar display
Diffstat (limited to 'client/src/app/shared/shared-account-avatar')
5 files changed, 0 insertions, 181 deletions
diff --git a/client/src/app/shared/shared-account-avatar/account-avatar.component.html b/client/src/app/shared/shared-account-avatar/account-avatar.component.html deleted file mode 100644 index 083daccfb..000000000 --- a/client/src/app/shared/shared-account-avatar/account-avatar.component.html +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | <ng-template #img> | ||
2 | <img *ngIf="avatarUrl || !initial" [class]="class" [src]="avatarUrl || defaultAvatarUrl" i18n-alt alt="Account avatar" /> | ||
3 | <div *ngIf="!avatarUrl && initial" [class]="class"> | ||
4 | <span>{{ initial }}</span> | ||
5 | </div> | ||
6 | </ng-template> | ||
7 | |||
8 | <a *ngIf="account && href" [href]="href" target="_blank" rel="noopener noreferrer" [title]="title"> | ||
9 | <ng-template *ngTemplateOutlet="img"></ng-template> | ||
10 | </a> | ||
11 | |||
12 | <a *ngIf="account && internalHref" [routerLink]="internalHref" [title]="title"> | ||
13 | <ng-template *ngTemplateOutlet="img"></ng-template> | ||
14 | </a> | ||
15 | |||
16 | <ng-container *ngIf="!account || (!href && !internalHref)"> | ||
17 | <ng-template *ngTemplateOutlet="img"></ng-template> | ||
18 | </ng-container> | ||
diff --git a/client/src/app/shared/shared-account-avatar/account-avatar.component.scss b/client/src/app/shared/shared-account-avatar/account-avatar.component.scss deleted file mode 100644 index 75a4cbf86..000000000 --- a/client/src/app/shared/shared-account-avatar/account-avatar.component.scss +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .avatar-25 { | ||
5 | @include avatar(25px); | ||
6 | } | ||
7 | |||
8 | .avatar-32 { | ||
9 | @include avatar(32px); | ||
10 | } | ||
11 | |||
12 | .avatar-34 { | ||
13 | @include avatar(34px); | ||
14 | } | ||
15 | |||
16 | .avatar-36 { | ||
17 | @include avatar(36px); | ||
18 | } | ||
19 | |||
20 | .avatar-40 { | ||
21 | @include avatar(40px); | ||
22 | } | ||
23 | |||
24 | .avatar-120 { | ||
25 | @include avatar(120px); | ||
26 | |||
27 | &.initial { | ||
28 | font-size: 46px; | ||
29 | } | ||
30 | } | ||
31 | |||
32 | a:hover { | ||
33 | text-decoration: none; | ||
34 | } | ||
35 | |||
36 | .initial { | ||
37 | background-color: #3C2109; | ||
38 | color: #fff; | ||
39 | display: flex; | ||
40 | align-items: center; | ||
41 | justify-content: center; | ||
42 | font-size: 22px; | ||
43 | border-radius: 50%; | ||
44 | |||
45 | &.blue { | ||
46 | background-color: #009FD4; | ||
47 | } | ||
48 | |||
49 | &.green { | ||
50 | background-color: #00AA55; | ||
51 | } | ||
52 | |||
53 | &.purple { | ||
54 | background-color: #B381B3; | ||
55 | } | ||
56 | |||
57 | &.gray { | ||
58 | background-color: #939393; | ||
59 | } | ||
60 | |||
61 | &.yellow { | ||
62 | background-color: #AA8F00; | ||
63 | } | ||
64 | |||
65 | &.orange { | ||
66 | background-color: #D47500; | ||
67 | } | ||
68 | |||
69 | &.red { | ||
70 | background-color: #E76E3C; | ||
71 | } | ||
72 | |||
73 | &.dark-blue { | ||
74 | background-color: #0A3055; | ||
75 | } | ||
76 | } | ||
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 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | import { 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 | }) | ||
9 | export 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 | } | ||
diff --git a/client/src/app/shared/shared-account-avatar/index.ts b/client/src/app/shared/shared-account-avatar/index.ts deleted file mode 100644 index 40c742ba5..000000000 --- a/client/src/app/shared/shared-account-avatar/index.ts +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | export * from './account-avatar.component' | ||
2 | export * from './shared-account-avatar.module' \ No newline at end of file | ||
diff --git a/client/src/app/shared/shared-account-avatar/shared-account-avatar.module.ts b/client/src/app/shared/shared-account-avatar/shared-account-avatar.module.ts deleted file mode 100644 index 17b27589f..000000000 --- a/client/src/app/shared/shared-account-avatar/shared-account-avatar.module.ts +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | |||
2 | import { NgModule } from '@angular/core' | ||
3 | import { SharedGlobalIconModule } from '../shared-icons' | ||
4 | import { SharedMainModule } from '../shared-main/shared-main.module' | ||
5 | import { AccountAvatarComponent } from './account-avatar.component' | ||
6 | |||
7 | @NgModule({ | ||
8 | imports: [ | ||
9 | SharedMainModule, | ||
10 | SharedGlobalIconModule | ||
11 | ], | ||
12 | |||
13 | declarations: [ | ||
14 | AccountAvatarComponent | ||
15 | ], | ||
16 | |||
17 | exports: [ | ||
18 | AccountAvatarComponent | ||
19 | ], | ||
20 | |||
21 | providers: [ ] | ||
22 | }) | ||
23 | export class SharedAccountAvatarModule { } | ||