2019-04-21 19:09:52 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 23:38:10 +09:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2023-10-25 02:45:08 +09:00
|
|
|
import { ReactComponent as UploadFileIcon } from '@material-symbols/svg-600/outlined/upload_file.svg';
|
2019-04-21 19:09:52 +09:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2023-05-28 23:38:10 +09:00
|
|
|
|
2023-11-15 21:19:17 +09:00
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
2023-05-28 23:38:10 +09:00
|
|
|
|
|
|
|
import Motion from '../../ui/util/optional_motion';
|
|
|
|
|
2023-05-28 21:18:23 +09:00
|
|
|
export default class UploadProgress extends PureComponent {
|
2019-04-21 19:09:52 +09:00
|
|
|
|
|
|
|
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'>
|
2023-10-25 02:45:08 +09:00
|
|
|
<Icon id='upload' icon={UploadFileIcon} />
|
2022-11-06 21:30:37 +09:00
|
|
|
</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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|