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