Fancier drag & drop indicator, emoji icon for emoji, upload progress (fix #295)
parent
3e2d6ea408
commit
d7c6c6dbe1
@ -0,0 +1,44 @@ |
||||
import PureRenderMixin from 'react-addons-pure-render-mixin'; |
||||
import { Motion, spring } from 'react-motion'; |
||||
import { FormattedMessage } from 'react-intl'; |
||||
|
||||
const UploadProgress = React.createClass({ |
||||
|
||||
propTypes: { |
||||
active: React.PropTypes.bool, |
||||
progress: React.PropTypes.number |
||||
}, |
||||
|
||||
mixins: [PureRenderMixin], |
||||
|
||||
render () { |
||||
const { active, progress } = this.props; |
||||
|
||||
if (!active) { |
||||
return null; |
||||
} |
||||
|
||||
return ( |
||||
<div className='upload-progress'> |
||||
<div> |
||||
<i className='fa fa-upload' /> |
||||
</div> |
||||
|
||||
<div style={{ flex: '1 1 auto' }}> |
||||
<FormattedMessage id='upload_progress.label' defaultMessage='Uploading...' /> |
||||
|
||||
<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> |
||||
); |
||||
} |
||||
|
||||
}); |
||||
|
||||
export default UploadProgress; |
@ -0,0 +1,9 @@ |
||||
import { connect } from 'react-redux'; |
||||
import UploadProgress from '../components/upload_progress'; |
||||
|
||||
const mapStateToProps = (state, props) => ({ |
||||
active: state.getIn(['compose', 'is_uploading']), |
||||
progress: state.getIn(['compose', 'progress']) |
||||
}); |
||||
|
||||
export default connect(mapStateToProps)(UploadProgress); |
@ -0,0 +1,32 @@ |
||||
import PureRenderMixin from 'react-addons-pure-render-mixin'; |
||||
import { Motion, spring } from 'react-motion'; |
||||
import { FormattedMessage } from 'react-intl'; |
||||
|
||||
const UploadArea = React.createClass({ |
||||
|
||||
propTypes: { |
||||
active: React.PropTypes.bool |
||||
}, |
||||
|
||||
mixins: [PureRenderMixin], |
||||
|
||||
render () { |
||||
const { active } = this.props; |
||||
|
||||
return ( |
||||
<Motion defaultStyle={{ backgroundOpacity: 0, backgroundScale: 0.95 }} style={{ backgroundOpacity: spring(active ? 1 : 0, { stiffness: 150, damping: 15 }), backgroundScale: spring(active ? 1 : 0.95, { stiffness: 200, damping: 3 }) }}> |
||||
{({ backgroundOpacity, backgroundScale }) => |
||||
<div className='upload-area' style={{ visibility: active ? 'visible' : 'hidden', opacity: backgroundOpacity }}> |
||||
<div className='upload-area__drop'> |
||||
<div className='upload-area__background' style={{ transform: `translateZ(0) scale(${backgroundScale})` }} /> |
||||
<div className='upload-area__content'><FormattedMessage id='upload_area.title' defaultMessage='Drag & drop to upload' /></div> |
||||
</div> |
||||
</div> |
||||
} |
||||
</Motion> |
||||
); |
||||
} |
||||
|
||||
}); |
||||
|
||||
export default UploadArea; |
Loading…
Reference in new issue