2017-01-16 22:04:02 +11:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { closeModal } from '../../../actions/modal';
|
|
|
|
import Lightbox from '../../../components/lightbox';
|
|
|
|
import ImageLoader from 'react-imageloader';
|
|
|
|
import LoadingIndicator from '../../../components/loading_indicator';
|
2016-10-25 03:07:40 +11:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
url: state.getIn(['modal', 'url']),
|
|
|
|
isVisible: state.getIn(['modal', 'open'])
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
onCloseClicked () {
|
|
|
|
dispatch(closeModal());
|
|
|
|
},
|
|
|
|
|
|
|
|
onOverlayClicked () {
|
|
|
|
dispatch(closeModal());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-11-08 04:23:36 +11:00
|
|
|
const imageStyle = {
|
|
|
|
display: 'block',
|
2016-11-11 09:21:24 +11:00
|
|
|
maxWidth: '80vw',
|
|
|
|
maxHeight: '80vh'
|
2016-10-25 03:07:40 +11:00
|
|
|
};
|
|
|
|
|
2017-01-17 05:36:32 +11:00
|
|
|
const loadingStyle = {
|
|
|
|
background: '#373b4a',
|
|
|
|
width: '400px',
|
|
|
|
paddingBottom: '120px'
|
|
|
|
};
|
|
|
|
|
|
|
|
const preloader = () => (
|
|
|
|
<div style={loadingStyle}>
|
|
|
|
<LoadingIndicator />
|
|
|
|
</div>
|
|
|
|
);
|
2017-01-16 22:04:02 +11:00
|
|
|
|
2016-10-25 03:07:40 +11:00
|
|
|
const Modal = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
url: React.PropTypes.string,
|
|
|
|
isVisible: React.PropTypes.bool,
|
|
|
|
onCloseClicked: React.PropTypes.func,
|
|
|
|
onOverlayClicked: React.PropTypes.func
|
|
|
|
},
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { url, ...other } = this.props;
|
|
|
|
|
|
|
|
return (
|
2016-11-08 04:23:36 +11:00
|
|
|
<Lightbox {...other}>
|
2017-01-16 22:04:02 +11:00
|
|
|
<ImageLoader
|
|
|
|
src={url}
|
|
|
|
preloader={preloader}
|
|
|
|
imgProps={{ style: imageStyle }}
|
|
|
|
/>
|
2016-11-08 04:23:36 +11:00
|
|
|
</Lightbox>
|
2016-10-25 03:07:40 +11:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Modal);
|