ProgressBar.js 885 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import Plugin from './Plugin'
  2. import yo from 'yo-yo'
  3. /**
  4. * Progress bar
  5. *
  6. */
  7. export default class ProgressBar extends Plugin {
  8. constructor (core, opts) {
  9. super(core, opts)
  10. this.id = 'ProgressBar'
  11. this.title = 'Progress Bar'
  12. this.type = 'progressindicator'
  13. // set default options
  14. const defaultOptions = {
  15. replaceTargetContent: false
  16. }
  17. // merge default options with the ones set by user
  18. this.opts = Object.assign({}, defaultOptions, opts)
  19. }
  20. render (state) {
  21. const progress = state.totalProgress || 0
  22. return yo`<div class="UppyProgressBar">
  23. <div class="UppyProgressBar-inner" style="width: ${progress}%"></div>
  24. <div class="UppyProgressBar-percentage">${progress}</div>
  25. </div>`
  26. }
  27. install () {
  28. const target = this.opts.target
  29. const plugin = this
  30. this.target = this.mount(target, plugin)
  31. }
  32. }