2016-10-24 16:07:40 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { closeModal } from '../../../actions/modal';
|
2016-11-07 17:23:36 +00:00
|
|
|
import Lightbox from '../../../components/lightbox';
|
2016-10-24 16:07:40 +00: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-07 17:23:36 +00:00
|
|
|
const imageStyle = {
|
|
|
|
display: 'block',
|
|
|
|
maxWidth: '100%',
|
|
|
|
height: 'auto',
|
|
|
|
margin: '0 auto'
|
2016-10-24 16:07:40 +00: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-07 17:23:36 +00:00
|
|
|
<Lightbox {...other}>
|
|
|
|
<img src={url} style={imageStyle} />
|
|
|
|
</Lightbox>
|
2016-10-24 16:07:40 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Modal);
|