Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to add loader to playlist #210

Merged
merged 3 commits into from
Jul 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var html = require('choo/html')
var css = require('csjs-inject')

module.exports = css`
var styles = css`
.loading {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 100pt;
}

.loader,
Expand Down Expand Up @@ -70,3 +70,11 @@ module.exports = css`
}
}
`

module.exports = function loader () {
return html`
<section class="${styles.loading}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this from div to section, to match the other main root node, it works. Probably a nanomnorph bug.

<div class="${styles.loader}"></div>
</section>
`
}
6 changes: 6 additions & 0 deletions renderer/elements/playlist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var html = require('choo/html')
var Component = require('cache-component')
var styles = require('./styles')
var TableRows = require('./rows')
var loader = require('../loader')

function Playlist (opts) {
if (!(this instanceof Playlist)) return new Playlist(opts)
Expand All @@ -17,6 +18,10 @@ function Playlist (opts) {
Playlist.prototype = Object.create(Component.prototype)

Playlist.prototype._render = function (state, emit) {
this._loading = state.library.loading

if (this._loading) return loader()

return html`
<section class="${styles.pane}">
<div class=${styles.tableHeader}>
Expand All @@ -40,6 +45,7 @@ Playlist.prototype._render = function (state, emit) {
}

Playlist.prototype._update = function (state, emit) {
if (this._loading !== state.library.loading) return true
if (this._tableRows._update(state, emit)) return true
return false
}
Expand Down