Merge pull request #14 from feross/hyperx-pr
Use class instead of className; use standard html
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
"create-torrent": "^3.22.1",
|
"create-torrent": "^3.22.1",
|
||||||
"debug": "^2.2.0",
|
"debug": "^2.2.0",
|
||||||
"drag-drop": "^2.3.1",
|
"drag-drop": "^2.3.1",
|
||||||
"hyperx": "^1.4.0",
|
"hyperx": "^2.0.0",
|
||||||
"network-address": "^1.1.0",
|
"network-address": "^1.1.0",
|
||||||
"pretty-bytes": "^3.0.0",
|
"pretty-bytes": "^3.0.0",
|
||||||
"throttleit": "^1.0.0",
|
"throttleit": "^1.0.0",
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ function App (state, dispatch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return hx`
|
return hx`
|
||||||
<div.app>
|
<div class="app">
|
||||||
${Header(state, dispatch)}
|
${Header(state, dispatch)}
|
||||||
<div.content>${getView()}</div>
|
<div class="content">${getView()}</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ var hx = hyperx(h)
|
|||||||
|
|
||||||
function Header (state, dispatch) {
|
function Header (state, dispatch) {
|
||||||
return hx`
|
return hx`
|
||||||
<div.header>
|
<div class="header">
|
||||||
${getTitle()}
|
${getTitle()}
|
||||||
<div.nav.left>
|
<div class="nav left">
|
||||||
<i.icon.back onclick=${onBack}>chevron_left</i>
|
<i class="icon back" onclick=${onBack}>chevron_left</i>
|
||||||
<i.icon.forward onclick=${onForward}>chevron_right</i>
|
<i class="icon forward" onclick=${onForward}>chevron_right</i>
|
||||||
</div>
|
</div>
|
||||||
<div.nav.right>
|
<div class="nav right">
|
||||||
${plusButton()}
|
${plusButton()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -20,13 +20,13 @@ function Header (state, dispatch) {
|
|||||||
|
|
||||||
function getTitle () {
|
function getTitle () {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
return hx`<div.title>${state.view.title}</div>`
|
return hx`<div class="title">${state.view.title}</div>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function plusButton () {
|
function plusButton () {
|
||||||
if (state.view.url !== '/player') {
|
if (state.view.url !== '/player') {
|
||||||
return hx`<i.icon.add onclick=${onAddTorrent}>add</i>`
|
return hx`<i class="icon add" onclick=${onAddTorrent}>add</i>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function Player (state, dispatch) {
|
|||||||
|
|
||||||
// Show the video as large as will fit in the window, play immediately
|
// Show the video as large as will fit in the window, play immediately
|
||||||
return hx`
|
return hx`
|
||||||
<div.player>
|
<div class="player">
|
||||||
<video
|
<video
|
||||||
src="${state.server.localURL}"
|
src="${state.server.localURL}"
|
||||||
onloadedmetadata="${onLoadedMetadata}"
|
onloadedmetadata="${onLoadedMetadata}"
|
||||||
@@ -55,15 +55,15 @@ function renderPlayerControls (state, dispatch) {
|
|||||||
var playbackCursorStyle = { left: 'calc(' + positionPercent + '% - 4px)' }
|
var playbackCursorStyle = { left: 'calc(' + positionPercent + '% - 4px)' }
|
||||||
|
|
||||||
return hx`
|
return hx`
|
||||||
<div.player-controls>
|
<div class="player-controls">
|
||||||
<div.scrub-bar
|
<div class="scrub-bar"
|
||||||
draggable="true"
|
draggable="true"
|
||||||
onclick=${handleScrub},
|
onclick=${handleScrub},
|
||||||
ondrag=${handleScrub}>
|
ondrag=${handleScrub}>
|
||||||
${renderLoadingBar(state)}
|
${renderLoadingBar(state)}
|
||||||
<div.playback-cursor style=${playbackCursorStyle}></div>
|
<div class="playback-cursor" style=${playbackCursorStyle}></div>
|
||||||
</div>
|
</div>
|
||||||
<i.icon.play-pause onclick=${() => dispatch('playPause')}>
|
<i class="icon play-pause" onclick=${() => dispatch('playPause')}>
|
||||||
${state.video.isPaused ? 'play_arrow' : 'pause'}
|
${state.video.isPaused ? 'play_arrow' : 'pause'}
|
||||||
</i>
|
</i>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,14 +104,14 @@ function renderLoadingBar (state) {
|
|||||||
|
|
||||||
// Output an list of rectangles to show loading progress
|
// Output an list of rectangles to show loading progress
|
||||||
return hx`
|
return hx`
|
||||||
<div.loading-bar>
|
<div class="loading-bar">
|
||||||
${parts.map(function (part) {
|
${parts.map(function (part) {
|
||||||
var style = {
|
var style = {
|
||||||
left: (100 * part.start / numParts) + '%',
|
left: (100 * part.start / numParts) + '%',
|
||||||
width: (100 * part.count / numParts) + '%'
|
width: (100 * part.count / numParts) + '%'
|
||||||
}
|
}
|
||||||
|
|
||||||
return hx`<div.loading-bar-part style=${style}></div>`
|
return hx`<div class="loading-bar-part" style=${style}></div>`
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ function TorrentList (state, dispatch) {
|
|||||||
: []
|
: []
|
||||||
|
|
||||||
var list = torrents.map((torrent) => renderTorrent(state, dispatch, torrent))
|
var list = torrents.map((torrent) => renderTorrent(state, dispatch, torrent))
|
||||||
return hx`<div.torrent-list>${list}</div>`
|
return hx`<div class="torrent-list">${list}</div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renders a torrent in the torrent list
|
// Renders a torrent in the torrent list
|
||||||
@@ -29,14 +29,15 @@ function renderTorrent (state, dispatch, torrent) {
|
|||||||
var elements = [
|
var elements = [
|
||||||
renderTorrentMetadata(torrent),
|
renderTorrentMetadata(torrent),
|
||||||
hx`
|
hx`
|
||||||
<i.icon.delete
|
<i
|
||||||
|
class="icon delete"
|
||||||
onclick=${() => dispatch('deleteTorrent', torrent)}>
|
onclick=${() => dispatch('deleteTorrent', torrent)}>
|
||||||
close
|
close
|
||||||
</i>
|
</i>
|
||||||
`,
|
`,
|
||||||
hx`
|
hx`
|
||||||
<i.btn.icon.play
|
<i.btn.icon.play
|
||||||
className="${!torrent.ready ? 'disabled' : ''}"
|
class="${!torrent.ready ? 'disabled' : ''}"
|
||||||
onclick=${() => dispatch('openPlayer', torrent)}>
|
onclick=${() => dispatch('openPlayer', torrent)}>
|
||||||
play_arrow
|
play_arrow
|
||||||
</i>
|
</i>
|
||||||
@@ -46,7 +47,7 @@ function renderTorrent (state, dispatch, torrent) {
|
|||||||
if (state.view.chromecast) {
|
if (state.view.chromecast) {
|
||||||
elements.push(hx`
|
elements.push(hx`
|
||||||
<i.btn.icon.chromecast
|
<i.btn.icon.chromecast
|
||||||
className="${!torrent.ready ? 'disabled' : ''}"
|
class="${!torrent.ready ? 'disabled' : ''}"
|
||||||
onclick=${() => dispatch('openChromecast', torrent)}>
|
onclick=${() => dispatch('openChromecast', torrent)}>
|
||||||
cast
|
cast
|
||||||
</i>
|
</i>
|
||||||
@@ -56,23 +57,23 @@ function renderTorrent (state, dispatch, torrent) {
|
|||||||
if (state.view.devices.airplay) {
|
if (state.view.devices.airplay) {
|
||||||
elements.push(hx`
|
elements.push(hx`
|
||||||
<i.btn.icon.airplay
|
<i.btn.icon.airplay
|
||||||
className="${!torrent.ready ? 'disabled' : ''}"
|
class="${!torrent.ready ? 'disabled' : ''}"
|
||||||
onclick=${() => dispatch('openAirplay', torrent)}>
|
onclick=${() => dispatch('openAirplay', torrent)}>
|
||||||
airplay
|
airplay
|
||||||
</i>
|
</i>
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return hx`<div.torrent style=${style}>${elements}</div>`
|
return hx`<div class="torrent" style=${style}>${elements}</div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renders the torrent name and download progress
|
// Renders the torrent name and download progress
|
||||||
function renderTorrentMetadata (torrent) {
|
function renderTorrentMetadata (torrent) {
|
||||||
return hx`
|
return hx`
|
||||||
<div.metadata>
|
<div class="metadata">
|
||||||
<div.name.ellipsis>${torrent.name || 'Loading torrent...'}</div>
|
<div class="name ellipsis">${torrent.name || 'Loading torrent...'}</div>
|
||||||
<div.status>
|
<div class="status">
|
||||||
<span.progress>${Math.floor(100 * torrent.progress)}%</span>
|
<span class="progress">${Math.floor(100 * torrent.progress)}%</span>
|
||||||
</div>
|
</div>
|
||||||
${getFilesLength()}
|
${getFilesLength()}
|
||||||
<span>${getPeers()}</span>
|
<span>${getPeers()}</span>
|
||||||
@@ -88,7 +89,7 @@ function renderTorrentMetadata (torrent) {
|
|||||||
|
|
||||||
function getFilesLength () {
|
function getFilesLength () {
|
||||||
if (torrent.ready && torrent.files.length > 1) {
|
if (torrent.ready && torrent.files.length > 1) {
|
||||||
return hx`<span.files>${torrent.files.length} files</span>`
|
return hx`<span class="files">${torrent.files.length} files</span>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user