2019-04-21 03:09:52 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 07:38:10 -07:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2019-04-21 03:09:52 -07:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2023-05-28 07:38:10 -07:00
|
|
|
|
2023-05-08 18:11:56 -07:00
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
2023-05-28 07:38:10 -07:00
|
|
|
|
|
|
|
import Motion from '../../ui/util/optional_motion';
|
|
|
|
|
2023-05-28 05:18:23 -07:00
|
|
|
export default class UploadProgress extends PureComponent {
|
2019-04-21 03:09:52 -07:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
|
|
|
progress: PropTypes.number,
|
2022-10-29 11:05:53 -07:00
|
|
|
isProcessing: PropTypes.bool,
|
2019-04-21 03:09:52 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2022-10-29 11:05:53 -07:00
|
|
|
const { active, progress, isProcessing } = this.props;
|
2019-04-21 03:09:52 -07:00
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-10-29 11:05:53 -07: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 03:09:52 -07:00
|
|
|
return (
|
2022-11-06 04:30:37 -08:00
|
|
|
<div className='upload-progress'>
|
|
|
|
<div className='upload-progress__icon'>
|
|
|
|
<Icon id='upload' />
|
|
|
|
</div>
|
2019-04-21 03:09:52 -07:00
|
|
|
|
2022-11-06 04:30:37 -08:00
|
|
|
<div className='upload-progress__message'>
|
2019-08-19 11:53:28 -07:00
|
|
|
{message}
|
2019-04-21 03:09:52 -07:00
|
|
|
|
2022-11-06 04:30:37 -08:00
|
|
|
<div className='upload-progress__backdrop'>
|
2019-04-21 03:09:52 -07:00
|
|
|
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
|
|
|
|
{({ width }) =>
|
2022-11-06 04:30:37 -08:00
|
|
|
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
|
2019-04-21 03:09:52 -07:00
|
|
|
}
|
|
|
|
</Motion>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|