separation of concerns
This commit is contained in:
43
renderer/views/header.js
Normal file
43
renderer/views/header.js
Normal file
@@ -0,0 +1,43 @@
|
||||
module.exports = Header
|
||||
|
||||
var h = require('virtual-dom/h')
|
||||
|
||||
function Header (state, dispatch) {
|
||||
return h('.header', [
|
||||
(function () {
|
||||
if (process.platform === 'darwin') {
|
||||
return h('.title', state.view.title)
|
||||
}
|
||||
})(),
|
||||
h('.nav.left', [
|
||||
h('i.icon.back', {
|
||||
onclick: onBack
|
||||
}, 'chevron_left'),
|
||||
h('i.icon.forward', {
|
||||
onclick: onForward
|
||||
}, 'chevron_right')
|
||||
]),
|
||||
(function () {
|
||||
if (state.url !== '/player') {
|
||||
return h('.nav.right', [
|
||||
h('i.icon.add', {
|
||||
onclick: onAddTorrent
|
||||
}, 'add')
|
||||
])
|
||||
}
|
||||
})()
|
||||
])
|
||||
|
||||
function onBack (e) {
|
||||
dispatch('back')
|
||||
}
|
||||
|
||||
function onForward (e) {
|
||||
dispatch('forward')
|
||||
}
|
||||
|
||||
function onAddTorrent (e) {
|
||||
var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4'
|
||||
dispatch('addTorrent', torrentId)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user