diff options
Diffstat (limited to 'client/src/app/shared/shared-account-avatar')
5 files changed, 93 insertions, 0 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 new file mode 100644 index 000000000..6bec0b5f3 --- /dev/null +++ b/client/src/app/shared/shared-account-avatar/account-avatar.component.html | |||
@@ -0,0 +1,8 @@ | |||
1 | <a *ngIf="account" [href]="href" target="_blank" rel="noopener noreferrer" [title]="title"> | ||
2 | <img | ||
3 | [class]="class" | ||
4 | [src]="avatarUrl" | ||
5 | i18n-alt | ||
6 | alt="Account avatar" | ||
7 | /> | ||
8 | </a> | ||
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 new file mode 100644 index 000000000..bb941d712 --- /dev/null +++ b/client/src/app/shared/shared-account-avatar/account-avatar.component.scss | |||
@@ -0,0 +1,22 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .avatar-25 { | ||
5 | @include avatar(25px); | ||
6 | } | ||
7 | |||
8 | .avatar-34 { | ||
9 | @include avatar(34px); | ||
10 | } | ||
11 | |||
12 | .avatar-36 { | ||
13 | @include avatar(36px); | ||
14 | } | ||
15 | |||
16 | .avatar-40 { | ||
17 | @include avatar(40px); | ||
18 | } | ||
19 | |||
20 | .avatar-120 { | ||
21 | @include avatar(120px); | ||
22 | } \ No newline at end of file | ||
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 | } | ||
diff --git a/client/src/app/shared/shared-account-avatar/index.ts b/client/src/app/shared/shared-account-avatar/index.ts new file mode 100644 index 000000000..40c742ba5 --- /dev/null +++ b/client/src/app/shared/shared-account-avatar/index.ts | |||
@@ -0,0 +1,2 @@ | |||
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 new file mode 100644 index 000000000..17b27589f --- /dev/null +++ b/client/src/app/shared/shared-account-avatar/shared-account-avatar.module.ts | |||
@@ -0,0 +1,23 @@ | |||
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 { } | ||