bigbuffet-rw/app/soapbox/features/compose/components/upload_progress.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import PropTypes from 'prop-types';
import React from 'react';
2020-03-27 13:59:38 -07:00
import { FormattedMessage } from 'react-intl';
import spring from 'react-motion/lib/spring';
2020-05-28 15:52:07 -07:00
import Icon from 'soapbox/components/icon';
2022-01-10 14:01:24 -08:00
import Motion from '../../ui/util/optional_motion';
2020-03-27 13:59:38 -07:00
export default class UploadProgress extends React.PureComponent {
static propTypes = {
active: PropTypes.bool,
progress: PropTypes.number,
};
render() {
2020-03-27 13:59:38 -07:00
const { active, progress } = this.props;
if (!active) {
return null;
}
return (
<div className='upload-progress'>
<div className='upload-progress__icon'>
<Icon id='upload' />
</div>
<div className='upload-progress__message'>
<FormattedMessage id='upload_progress.label' defaultMessage='Uploading…' />
2020-03-27 13:59:38 -07:00
<div className='upload-progress__backdrop'>
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
{({ width }) =>
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
}
</Motion>
</div>
</div>
</div>
);
}
}