uppy/packages/@uppy/react/src/ProgressBar.js
2018-06-18 10:14:08 +02:00

50 lines
1 KiB
JavaScript

const React = require('react')
const PropTypes = require('prop-types')
const ProgressBarPlugin = require('@uppy/progress-bar')
const uppyPropType = require('./propTypes').uppy
const h = React.createElement
/**
* React component that renders a progress bar at the top of the page.
*/
class ProgressBar extends React.Component {
componentDidMount () {
const uppy = this.props.uppy
const options = Object.assign(
{ id: 'react:ProgressBar' },
this.props,
{ target: this.container }
)
delete options.uppy
uppy.use(ProgressBarPlugin, options)
this.plugin = uppy.getPlugin(options.id)
}
componentWillUnmount () {
const uppy = this.props.uppy
uppy.removePlugin(this.plugin)
}
render () {
return h('div', {
ref: (container) => {
this.container = container
}
})
}
}
ProgressBar.propTypes = {
uppy: uppyPropType,
fixed: PropTypes.bool,
hideAfterFinish: PropTypes.bool
}
ProgressBar.defaultProps = {
}
module.exports = ProgressBar