aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/dock/peertube-dock-component.ts
blob: 183c7a00f926839f5926ce60fdac9f9ba6acbd3a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import videojs from 'video.js'

const Component = videojs.getComponent('Component')

export type PeerTubeDockComponentOptions = {
  title?: string
  description?: string
  avatarUrl?: string
}

class PeerTubeDockComponent extends Component {

  createEl () {
    const options = this.options_ as PeerTubeDockComponentOptions

    const el = super.createEl('div', {
      className: 'peertube-dock'
    })

    if (options.avatarUrl) {
      const avatar = videojs.dom.createEl('img', {
        className: 'peertube-dock-avatar',
        src: options.avatarUrl
      })

      el.appendChild(avatar)
    }

    const elWrapperTitleDescription = super.createEl('div', {
      className: 'peertube-dock-title-description'
    })

    if (options.title) {
      const title = videojs.dom.createEl('div', {
        className: 'peertube-dock-title',
        title: options.title,
        innerHTML: options.title
      })

      elWrapperTitleDescription.appendChild(title)
    }

    if (options.description) {
      const description = videojs.dom.createEl('div', {
        className: 'peertube-dock-description',
        title: options.description,
        innerHTML: options.description
      })

      elWrapperTitleDescription.appendChild(description)
    }

    if (options.title || options.description) {
      el.appendChild(elWrapperTitleDescription)
    }

    return el
  }
}

videojs.registerComponent('PeerTubeDockComponent', PeerTubeDockComponent)

export {
  PeerTubeDockComponent
}