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.

61 lines
1.5 KiB

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