-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
40 lines (34 loc) · 1 KB
/
index.js
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
const html = require('choo/html')
const Component = require('nanocomponent')
const Header = require('../../elements/header')
const styles = require('./styles')
const TrackView = require('./track-view')
const loader = require('../loader')
class Playlist extends Component {
constructor (opts) {
if (!opts) opts = {}
super(opts)
this.opts = Object.assign({}, opts)
// Owned Children
this.header = new Header()
this.trackView = new TrackView()
}
createElement (state, emit) {
this.loading = state.library.loading
return html`
<div class="${styles.playlist}">
${this.header.render(state, emit)}
${this.loading /* eslint-disable indent */
? loader()
: this.trackView.render(state, emit)/* eslint-enable indent */}
</div>
`
}
update (state, emit) {
if (this.loading !== state.library.loading) return true
this.trackView.render(state, emit)
this.header.render(state, emit)
return false
}
}
module.exports = Playlist