mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-23 18:29:09 +00:00
41 lines
1,014 B
JavaScript
41 lines
1,014 B
JavaScript
import Plugin from './Plugin'
|
|
import html from '../core/html'
|
|
|
|
/**
|
|
* Progress bar
|
|
*
|
|
*/
|
|
export default class ProgressBar extends Plugin {
|
|
constructor (core, opts) {
|
|
super(core, opts)
|
|
this.id = 'ProgressBar'
|
|
this.title = 'Progress Bar'
|
|
this.type = 'progressindicator'
|
|
|
|
// set default options
|
|
const defaultOptions = {
|
|
replaceTargetContent: false,
|
|
fixed: false
|
|
}
|
|
|
|
// merge default options with the ones set by user
|
|
this.opts = Object.assign({}, defaultOptions, opts)
|
|
|
|
this.render = this.render.bind(this)
|
|
}
|
|
|
|
render (state) {
|
|
const progress = state.totalProgress || 0
|
|
|
|
return html`<div class="UppyProgressBar" style="${this.opts.fixed ? 'position: fixed' : 'null'}">
|
|
<div class="UppyProgressBar-inner" style="width: ${progress}%"></div>
|
|
<div class="UppyProgressBar-percentage">${progress}</div>
|
|
</div>`
|
|
}
|
|
|
|
install () {
|
|
const target = this.opts.target
|
|
const plugin = this
|
|
this.target = this.mount(target, plugin)
|
|
}
|
|
}
|