diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-16 16:05:40 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-01-17 10:38:18 +0100 |
commit | 457bb213b273a9b206cc5654eb085cede4e916ad (patch) | |
tree | 6b1a317872a4ca27b5d0dbe543452320b26aacff /client/src/app/shared/icons | |
parent | 848f499def54db2dd36437ef0dfb74dd5041c23b (diff) | |
download | PeerTube-457bb213b273a9b206cc5654eb085cede4e916ad.tar.gz PeerTube-457bb213b273a9b206cc5654eb085cede4e916ad.tar.zst PeerTube-457bb213b273a9b206cc5654eb085cede4e916ad.zip |
Refactor how we use icons
Inject them in an angular component so we can easily change their color
Diffstat (limited to 'client/src/app/shared/icons')
-rw-r--r-- | client/src/app/shared/icons/global-icon.component.html | 0 | ||||
-rw-r--r-- | client/src/app/shared/icons/global-icon.component.scss | 4 | ||||
-rw-r--r-- | client/src/app/shared/icons/global-icon.component.ts | 47 |
3 files changed, 51 insertions, 0 deletions
diff --git a/client/src/app/shared/icons/global-icon.component.html b/client/src/app/shared/icons/global-icon.component.html new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/client/src/app/shared/icons/global-icon.component.html | |||
diff --git a/client/src/app/shared/icons/global-icon.component.scss b/client/src/app/shared/icons/global-icon.component.scss new file mode 100644 index 000000000..6805fb6f7 --- /dev/null +++ b/client/src/app/shared/icons/global-icon.component.scss | |||
@@ -0,0 +1,4 @@ | |||
1 | /deep/ svg { | ||
2 | width: inherit; | ||
3 | height: inherit; | ||
4 | } | ||
diff --git a/client/src/app/shared/icons/global-icon.component.ts b/client/src/app/shared/icons/global-icon.component.ts new file mode 100644 index 000000000..5b9377e3e --- /dev/null +++ b/client/src/app/shared/icons/global-icon.component.ts | |||
@@ -0,0 +1,47 @@ | |||
1 | import { Component, ElementRef, Input, OnInit } from '@angular/core' | ||
2 | |||
3 | const icons = { | ||
4 | 'add': require('../../../assets/images/global/add.html'), | ||
5 | 'syndication': require('../../../assets/images/global/syndication.html'), | ||
6 | 'help': require('../../../assets/images/global/help.html'), | ||
7 | 'sparkle': require('../../../assets/images/global/sparkle.html'), | ||
8 | 'alert': require('../../../assets/images/global/alert.html'), | ||
9 | 'cloud-error': require('../../../assets/images/global/cloud-error.html'), | ||
10 | 'user-add': require('../../../assets/images/global/user-add.html'), | ||
11 | 'no': require('../../../assets/images/global/no.html'), | ||
12 | 'cloud-download': require('../../../assets/images/global/cloud-download.html'), | ||
13 | 'undo': require('../../../assets/images/global/undo.html'), | ||
14 | 'circle-tick': require('../../../assets/images/global/circle-tick.html'), | ||
15 | 'cog': require('../../../assets/images/global/cog.html'), | ||
16 | 'download': require('../../../assets/images/global/download.html'), | ||
17 | 'edit': require('../../../assets/images/global/edit.html'), | ||
18 | 'im-with-her': require('../../../assets/images/global/im-with-her.html'), | ||
19 | 'delete': require('../../../assets/images/global/delete.html'), | ||
20 | 'cross': require('../../../assets/images/global/cross.html'), | ||
21 | 'validate': require('../../../assets/images/global/validate.html'), | ||
22 | 'dislike': require('../../../assets/images/video/dislike.html'), | ||
23 | 'heart': require('../../../assets/images/video/heart.html'), | ||
24 | 'like': require('../../../assets/images/video/like.html'), | ||
25 | 'more': require('../../../assets/images/video/more.html'), | ||
26 | 'share': require('../../../assets/images/video/share.html'), | ||
27 | 'upload': require('../../../assets/images/video/upload.html') | ||
28 | } | ||
29 | |||
30 | export type GlobalIconName = keyof typeof icons | ||
31 | |||
32 | @Component({ | ||
33 | selector: 'my-global-icon', | ||
34 | template: '', | ||
35 | styleUrls: [ './global-icon.component.scss' ] | ||
36 | }) | ||
37 | export class GlobalIconComponent implements OnInit { | ||
38 | @Input() iconName: GlobalIconName | ||
39 | |||
40 | constructor (private el: ElementRef) {} | ||
41 | |||
42 | ngOnInit () { | ||
43 | const nativeElement = this.el.nativeElement | ||
44 | |||
45 | nativeElement.innerHTML = icons[this.iconName] | ||
46 | } | ||
47 | } | ||