2019-04-21 10:09:52 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2022-10-11 08:51:33 +00:00
|
|
|
import Motion from '../../ui/util/optional_motion';
|
2019-04-21 10:09:52 +00:00
|
|
|
import spring from 'react-motion/lib/spring';
|
|
|
|
import Icon from 'flavours/glitch/components/icon';
|
2022-10-29 18:05:53 +00:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2019-04-21 10:09:52 +00:00
|
|
|
|
|
|
|
export default class UploadProgress extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
|
|
|
progress: PropTypes.number,
|
2022-10-29 18:05:53 +00:00
|
|
|
isProcessing: PropTypes.bool,
|
2019-04-21 10:09:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2022-10-29 18:05:53 +00:00
|
|
|
const { active, progress, isProcessing } = this.props;
|
2019-04-21 10:09:52 +00:00
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-10-29 18:05:53 +00:00
|
|
|
let message;
|
|
|
|
|
|
|
|
if (isProcessing) {
|
|
|
|
message = <FormattedMessage id='upload_progress.processing' defaultMessage='Processing…' />;
|
|
|
|
} else {
|
|
|
|
message = <FormattedMessage id='upload_progress.label' defaultMessage='Uploading…' />;
|
|
|
|
}
|
|
|
|
|
2019-04-21 10:09:52 +00:00
|
|
|
return (
|
2022-11-06 12:30:37 +00:00
|
|
|
<div className='upload-progress'>
|
|
|
|
<div className='upload-progress__icon'>
|
|
|
|
<Icon id='upload' />
|
|
|
|
</div>
|
2019-04-21 10:09:52 +00:00
|
|
|
|
2022-11-06 12:30:37 +00:00
|
|
|
<div className='upload-progress__message'>
|
2019-08-19 18:53:28 +00:00
|
|
|
{message}
|
2019-04-21 10:09:52 +00:00
|
|
|
|
2022-11-06 12:30:37 +00:00
|
|
|
<div className='upload-progress__backdrop'>
|
2019-04-21 10:09:52 +00:00
|
|
|
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
|
|
|
|
{({ width }) =>
|
2022-11-06 12:30:37 +00:00
|
|
|
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
|
2019-04-21 10:09:52 +00:00
|
|
|
}
|
|
|
|
</Motion>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|