]>
Commit | Line | Data |
---|---|---|
28e0e40d | 1 | import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core' |
c2023a9f | 2 | import { HooksService } from '@app/core/plugins/hooks.service' |
457bb213 C |
3 | |
4 | const icons = { | |
c41c0e28 RK |
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, | |
345b4a22 | 10 | 'peertube-x': require('!!raw-loader?!../../../assets/images/misc/peertube-x.svg').default, |
c41c0e28 RK |
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 | |
ea7337cf RK |
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 | |
c41c0e28 RK |
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, | |
0a4cb95c | 40 | 'sign-in': require('!!raw-loader?!../../../assets/images/feather/log-in.svg').default, |
c41c0e28 RK |
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, | |
345b4a22 | 46 | 'user-x': require('!!raw-loader?!../../../assets/images/feather/user-x.svg').default, |
c41c0e28 RK |
47 | 'users': require('!!raw-loader?!../../../assets/images/feather/users.svg').default, |
48 | 'user-add': require('!!raw-loader?!../../../assets/images/feather/user-plus.svg').default, | |
c41c0e28 RK |
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, | |
bc99dfe5 RK |
67 | 'repeat': require('!!raw-loader?!../../../assets/images/feather/repeat.svg').default, |
68 | 'columns': require('!!raw-loader?!../../../assets/images/feather/columns.svg').default | |
457bb213 C |
69 | } |
70 | ||
71 | export type GlobalIconName = keyof typeof icons | |
72 | ||
73 | @Component({ | |
74 | selector: 'my-global-icon', | |
75 | template: '', | |
28e0e40d C |
76 | styleUrls: [ './global-icon.component.scss' ], |
77 | changeDetection: ChangeDetectionStrategy.OnPush | |
457bb213 C |
78 | }) |
79 | export class GlobalIconComponent implements OnInit { | |
80 | @Input() iconName: GlobalIconName | |
81 | ||
c2023a9f C |
82 | constructor ( |
83 | private el: ElementRef, | |
84 | private hooks: HooksService | |
85 | ) { } | |
457bb213 | 86 | |
c2023a9f | 87 | async ngOnInit () { |
7738273b | 88 | const nativeElement = this.el.nativeElement as HTMLElement |
c2023a9f C |
89 | nativeElement.innerHTML = await this.hooks.wrapFun( |
90 | this.getSVGContent.bind(this), | |
91 | { name: this.iconName }, | |
92 | 'common', | |
93 | 'filter:internal.common.svg-icons.get-content.params', | |
94 | 'filter:internal.common.svg-icons.get-content.result' | |
95 | ) | |
96 | } | |
97 | ||
98 | private getSVGContent (options: { name: string }) { | |
99 | return icons[options.name] | |
457bb213 C |
100 | } |
101 | } |