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