You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.6 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import IconButton from './icon_button';
  3. import { Motion, spring } from 'react-motion';
  4. import { injectIntl } from 'react-intl';
  5. const overlayStyle = {
  6. position: 'fixed',
  7. top: '0',
  8. left: '0',
  9. width: '100%',
  10. height: '100%',
  11. background: 'rgba(0, 0, 0, 0.5)',
  12. display: 'flex',
  13. justifyContent: 'center',
  14. alignContent: 'center',
  15. flexDirection: 'row',
  16. zIndex: '9999'
  17. };
  18. const dialogStyle = {
  19. color: '#282c37',
  20. boxShadow: '0 0 30px rgba(0, 0, 0, 0.8)',
  21. margin: 'auto',
  22. position: 'relative'
  23. };
  24. const closeStyle = {
  25. position: 'absolute',
  26. top: '4px',
  27. right: '4px'
  28. };
  29. const Lightbox = React.createClass({
  30. propTypes: {
  31. isVisible: React.PropTypes.bool,
  32. onOverlayClicked: React.PropTypes.func,
  33. onCloseClicked: React.PropTypes.func
  34. },
  35. mixins: [PureRenderMixin],
  36. render () {
  37. const { intl, isVisible, onOverlayClicked, onCloseClicked, children } = this.props;
  38. return (
  39. <div className='lightbox' style={{...overlayStyle, display: isVisible ? 'flex' : 'none'}} onClick={onOverlayClicked}>
  40. <Motion defaultStyle={{ y: -200 }} style={{ y: spring(isVisible ? 0 : -200) }}>
  41. {({ y }) =>
  42. <div style={{...dialogStyle, transform: `translateY(${y}px)`}}>
  43. <IconButton title={intl.formatMessage({ id: 'lightbox.close', defaultMessage: 'Close' })} icon='times' onClick={onCloseClicked} size={16} style={closeStyle} />
  44. {children}
  45. </div>
  46. }
  47. </Motion>
  48. </div>
  49. );
  50. }
  51. });
  52. export default injectIntl(Lightbox);