]>
Commit | Line | Data |
---|---|---|
1 | import videojs from 'video.js' | |
2 | ||
3 | const Component = videojs.getComponent('Component') | |
4 | ||
5 | export type PeerTubeDockComponentOptions = { | |
6 | title?: string | |
7 | description?: string | |
8 | avatarUrl?: string | |
9 | } | |
10 | ||
11 | class PeerTubeDockComponent extends Component { | |
12 | ||
13 | createEl () { | |
14 | const options = this.options_ as PeerTubeDockComponentOptions | |
15 | ||
16 | const el = super.createEl('div', { | |
17 | className: 'peertube-dock' | |
18 | }) | |
19 | ||
20 | if (options.avatarUrl) { | |
21 | const avatar = videojs.dom.createEl('img', { | |
22 | className: 'peertube-dock-avatar', | |
23 | src: options.avatarUrl | |
24 | }) | |
25 | ||
26 | el.appendChild(avatar) | |
27 | } | |
28 | ||
29 | const elWrapperTitleDescription = super.createEl('div', { | |
30 | className: 'peertube-dock-title-description' | |
31 | }) | |
32 | ||
33 | if (options.title) { | |
34 | const title = videojs.dom.createEl('div', { | |
35 | className: 'peertube-dock-title', | |
36 | title: options.title, | |
37 | innerHTML: options.title | |
38 | }) | |
39 | ||
40 | elWrapperTitleDescription.appendChild(title) | |
41 | } | |
42 | ||
43 | if (options.description) { | |
44 | const description = videojs.dom.createEl('div', { | |
45 | className: 'peertube-dock-description', | |
46 | title: options.description, | |
47 | innerHTML: options.description | |
48 | }) | |
49 | ||
50 | elWrapperTitleDescription.appendChild(description) | |
51 | } | |
52 | ||
53 | if (options.title || options.description) { | |
54 | el.appendChild(elWrapperTitleDescription) | |
55 | } | |
56 | ||
57 | return el | |
58 | } | |
59 | } | |
60 | ||
61 | videojs.registerComponent('PeerTubeDockComponent', PeerTubeDockComponent) | |
62 | ||
63 | export { | |
64 | PeerTubeDockComponent | |
65 | } |