2017-05-03 10:04:16 +10:00
|
|
|
import React from 'react';
|
2017-04-22 04:05:35 +10:00
|
|
|
import PropTypes from 'prop-types';
|
2017-10-16 18:36:15 +11:00
|
|
|
import Motion from '../../ui/util/optional_motion';
|
2017-05-20 22:58:13 +10:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2019-02-01 10:14:05 +11:00
|
|
|
import Icon from 'mastodon/components/icon';
|
2017-03-24 13:50:30 +11:00
|
|
|
|
2017-06-24 03:36:54 +10:00
|
|
|
export default class UploadProgress extends React.PureComponent {
|
2017-03-24 13:50:30 +11:00
|
|
|
|
2017-05-12 22:44:10 +10:00
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
2017-05-21 01:31:47 +10:00
|
|
|
progress: PropTypes.number,
|
2019-08-15 23:13:26 +10:00
|
|
|
icon: PropTypes.string.isRequired,
|
|
|
|
message: PropTypes.node.isRequired,
|
2017-05-12 22:44:10 +10:00
|
|
|
};
|
|
|
|
|
2017-03-24 13:50:30 +11:00
|
|
|
render () {
|
2019-08-15 23:13:26 +10:00
|
|
|
const { active, progress, icon, message } = this.props;
|
2017-03-24 13:50:30 +11:00
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='upload-progress'>
|
2017-04-23 12:26:55 +10:00
|
|
|
<div className='upload-progress__icon'>
|
2019-08-15 23:13:26 +10:00
|
|
|
<Icon id={icon} />
|
2017-03-24 13:50:30 +11:00
|
|
|
</div>
|
|
|
|
|
2017-04-23 12:26:55 +10:00
|
|
|
<div className='upload-progress__message'>
|
2019-08-15 23:13:26 +10:00
|
|
|
{message}
|
2017-03-24 13:50:30 +11:00
|
|
|
|
|
|
|
<div className='upload-progress__backdrop'>
|
|
|
|
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
|
|
|
|
{({ width }) =>
|
|
|
|
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
|
|
|
|
}
|
|
|
|
</Motion>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|