]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/shared-icons/global-icon.component.ts
Hide deleted comment message when no replies
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-icons / global-icon.component.ts
1 import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core'
2 import { HooksService } from '@app/core/plugins/hooks.service'
3
4 const icons = {
5 // misc icons
6 'npm': require('!!raw-loader?!../../../assets/images/misc/npm.svg').default,
7 'language': require('!!raw-loader?!../../../assets/images/misc/language.svg').default,
8 'video-lang': require('!!raw-loader?!../../../assets/images/misc/video-lang.svg').default,
9 'support': require('!!raw-loader?!../../../assets/images/misc/support.svg').default,
10 'peertube-x': require('!!raw-loader?!../../../assets/images/misc/peertube-x.svg').default,
11 'robot': require('!!raw-loader?!../../../assets/images/misc/miscellaneous-services.svg').default, // material ui
12 'videos': require('!!raw-loader?!../../../assets/images/misc/video-library.svg').default, // material ui
13 'history': require('!!raw-loader?!../../../assets/images/misc/history.svg').default, // material ui
14 'subscriptions': require('!!raw-loader?!../../../assets/images/misc/subscriptions.svg').default, // material ui
15 'playlist-add': require('!!raw-loader?!../../../assets/images/misc/playlist-add.svg').default, // material ui
16 'follower': require('!!raw-loader?!../../../assets/images/misc/account-arrow-left.svg').default, // material ui
17 'following': require('!!raw-loader?!../../../assets/images/misc/account-arrow-right.svg').default, // material ui
18
19 // feather icons
20 'flag': require('!!raw-loader?!../../../assets/images/feather/flag.svg').default,
21 'playlists': require('!!raw-loader?!../../../assets/images/feather/list.svg').default,
22 'syndication': require('!!raw-loader?!../../../assets/images/feather/syndication.svg').default,
23 'help': require('!!raw-loader?!../../../assets/images/feather/help.svg').default,
24 'alert': require('!!raw-loader?!../../../assets/images/feather/alert.svg').default,
25 'globe': require('!!raw-loader?!../../../assets/images/feather/globe.svg').default,
26 'home': require('!!raw-loader?!../../../assets/images/feather/home.svg').default,
27 'recently-added': require('!!raw-loader?!../../../assets/images/feather/recently-added.svg').default,
28 'trending': require('!!raw-loader?!../../../assets/images/feather/trending.svg').default,
29 'search': require('!!raw-loader?!../../../assets/images/feather/search.svg').default,
30 'upload': require('!!raw-loader?!../../../assets/images/feather/upload.svg').default,
31 'dislike': require('!!raw-loader?!../../../assets/images/feather/dislike.svg').default,
32 'like': require('!!raw-loader?!../../../assets/images/feather/like.svg').default,
33 'no': require('!!raw-loader?!../../../assets/images/feather/no.svg').default,
34 'cloud-download': require('!!raw-loader?!../../../assets/images/feather/cloud-download.svg').default,
35 'clock': require('!!raw-loader?!../../../assets/images/feather/clock.svg').default,
36 'cog': require('!!raw-loader?!../../../assets/images/feather/cog.svg').default,
37 'delete': require('!!raw-loader?!../../../assets/images/feather/delete.svg').default,
38 'inbox-full': require('!!raw-loader?!../../../assets/images/feather/inbox-full.svg').default,
39 'sign-out': require('!!raw-loader?!../../../assets/images/feather/log-out.svg').default,
40 'sign-in': require('!!raw-loader?!../../../assets/images/feather/log-in.svg').default,
41 'download': require('!!raw-loader?!../../../assets/images/feather/download.svg').default,
42 'ownership-change': require('!!raw-loader?!../../../assets/images/feather/share.svg').default,
43 'share': require('!!raw-loader?!../../../assets/images/feather/share-2.svg').default,
44 'channel': require('!!raw-loader?!../../../assets/images/feather/tv.svg').default,
45 'user': require('!!raw-loader?!../../../assets/images/feather/user.svg').default,
46 'user-x': require('!!raw-loader?!../../../assets/images/feather/user-x.svg').default,
47 'users': require('!!raw-loader?!../../../assets/images/feather/users.svg').default,
48 'user-add': require('!!raw-loader?!../../../assets/images/feather/user-plus.svg').default,
49 'add': require('!!raw-loader?!../../../assets/images/feather/plus-circle.svg').default,
50 'cloud-error': require('!!raw-loader?!../../../assets/images/feather/cloud-off.svg').default,
51 'undo': require('!!raw-loader?!../../../assets/images/feather/corner-up-left.svg').default,
52 'circle-tick': require('!!raw-loader?!../../../assets/images/feather/check-circle.svg').default,
53 'more-horizontal': require('!!raw-loader?!../../../assets/images/feather/more-horizontal.svg').default,
54 'more-vertical': require('!!raw-loader?!../../../assets/images/feather/more-vertical.svg').default,
55 'play': require('!!raw-loader?!../../../assets/images/feather/play.svg').default,
56 'p2p': require('!!raw-loader?!../../../assets/images/feather/airplay.svg').default,
57 'fullscreen': require('!!raw-loader?!../../../assets/images/feather/maximize.svg').default,
58 'exit-fullscreen': require('!!raw-loader?!../../../assets/images/feather/minimize.svg').default,
59 'film': require('!!raw-loader?!../../../assets/images/feather/film.svg').default,
60 'edit': require('!!raw-loader?!../../../assets/images/feather/edit-2.svg').default,
61 'sensitive': require('!!raw-loader?!../../../assets/images/feather/eye.svg').default,
62 'unsensitive': require('!!raw-loader?!../../../assets/images/feather/eye-off.svg').default,
63 'refresh': require('!!raw-loader?!../../../assets/images/feather/refresh-cw.svg').default,
64 'go': require('!!raw-loader?!../../../assets/images/feather/arrow-up-right.svg').default,
65 'cross': require('!!raw-loader?!../../../assets/images/feather/x.svg').default,
66 'tick': require('!!raw-loader?!../../../assets/images/feather/check.svg').default,
67 'columns': require('!!raw-loader?!../../../assets/images/feather/columns.svg').default,
68 'repeat': require('!!raw-loader?!../../../assets/images/feather/repeat.svg').default,
69 'message-circle': require('!!raw-loader?!../../../assets/images/feather/message-circle.svg').default
70 }
71
72 export type GlobalIconName = keyof typeof icons
73
74 @Component({
75 selector: 'my-global-icon',
76 template: '',
77 styleUrls: [ './global-icon.component.scss' ],
78 changeDetection: ChangeDetectionStrategy.OnPush
79 })
80 export class GlobalIconComponent implements OnInit {
81 @Input() iconName: GlobalIconName
82
83 constructor (
84 private el: ElementRef,
85 private hooks: HooksService
86 ) { }
87
88 async ngOnInit () {
89 const nativeElement = this.el.nativeElement as HTMLElement
90 nativeElement.innerHTML = await this.hooks.wrapFun(
91 this.getSVGContent.bind(this),
92 { name: this.iconName },
93 'common',
94 'filter:internal.common.svg-icons.get-content.params',
95 'filter:internal.common.svg-icons.get-content.result'
96 )
97 }
98
99 private getSVGContent (options: { name: string }) {
100 return icons[options.name]
101 }
102 }