about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/ui/containers/modal_container.jsx
blob: 323125e3028eac1b75df775c4a6ba243376cdce9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { connect }           from 'react-redux';
import { SkyLightStateless } from 'react-skylight';
import { closeModal }        from '../../../actions/modal';

const mapStateToProps = state => ({
  url: state.getIn(['modal', 'url']),
  isVisible: state.getIn(['modal', 'open'])
});

const mapDispatchToProps = dispatch => ({
  onCloseClicked () {
    dispatch(closeModal());
  },

  onOverlayClicked () {
    dispatch(closeModal());
  }
});

const styles = {
  overlayStyles: {

  },

  dialogStyles: {
    width: '600px',
    color: '#282c37',
    fontSize: '16px',
    lineHeight: '37px',
    marginTop: '-300px',
    left: '0',
    right: '0',
    marginLeft: 'auto',
    marginRight: 'auto',
    height: 'auto'
  },

  imageStyle: {
    display: 'block',
    maxWidth: '100%',
    height: 'auto',
    margin: '0 auto'
  }
};

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 (
      <SkyLightStateless {...other} dialogStyles={styles.dialogStyles} overlayStyles={styles.overlayStyles}>
        <img src={url} style={styles.imageStyle} />
      </SkyLightStateless>
    );
  }

});

export default connect(mapStateToProps, mapDispatchToProps)(Modal);