From aaae797a0f3aa2d7fe0fbffb8d2e18093ab84a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Mon, 18 Sep 2017 08:48:12 +0200 Subject: [PATCH] react: revert UppyWrapper version of --- src/uppy-react/ProgressBar.js | 42 ++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/uppy-react/ProgressBar.js b/src/uppy-react/ProgressBar.js index 800679271..22149e766 100644 --- a/src/uppy-react/ProgressBar.js +++ b/src/uppy-react/ProgressBar.js @@ -1,23 +1,49 @@ const React = require('react') const PropTypes = require('prop-types') -const UppyCore = require('../core/Core') -const UppyWrapper = require('./Wrapper') +const UppyCore = require('../core') +const DragDropPlugin = require('../plugins/ProgressBar') const h = React.createElement /** - * React component that renders an area in which files can be dropped to be - * uploaded. + * React component that renders a progress bar at the top of the page. */ -const ProgressBar = (props) => - h(UppyWrapper, props) +class ProgressBar extends React.Component { + componentDidMount () { + const uppy = this.props.uppy + const options = Object.assign( + {}, + this.props, + { target: this.container } + ) + delete options.uppy + + uppy.use(DragDropPlugin, options) + + this.plugin = uppy.getPlugin('ProgressBar') + } + + componentWillUnmount () { + const uppy = this.props.uppy + + uppy.removePlugin(this.plugin) + } + + render () { + return h('div', { + ref: (container) => { + this.container = container + } + }) + } +} ProgressBar.propTypes = { - uppy: PropTypes.instanceOf(UppyCore).isRequired + uppy: PropTypes.instanceOf(UppyCore).isRequired, + fixed: PropTypes.bool } ProgressBar.defaultProps = { - plugin: 'ProgressBar' } module.exports = ProgressBar