Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3.  
  4. class Modal extends React.Component {
  5. render() {
  6. // Render nothing if the "show" prop is false
  7. if(!this.props.show) {
  8. return null;
  9. }
  10.  
  11. // The gray background
  12. const backdropStyle = {
  13. position: 'fixed',
  14. top: 0,
  15. bottom: 0,
  16. left: 0,
  17. right: 0,
  18. backgroundColor: 'rgba(0,0,0,0.3)',
  19. padding: 50
  20. };
  21.  
  22. // The modal "window"
  23. const modalStyle = {
  24. backgroundColor: '#fff',
  25. borderRadius: 5,
  26. maxWidth: 500,
  27. minHeight: 300,
  28. margin: '0 auto',
  29. padding: 30
  30. };
  31.  
  32. return (
  33. <div className="backdrop" style={backdropStyle}>
  34. <div className="modal" style={modalStyle}>
  35. {this.props.children}
  36.  
  37. <div className="footer">
  38. <button onClick={this.props.onClose}>
  39. Close
  40. </button>
  41. </div>
  42. </div>
  43. </div>
  44. );
  45. }
  46. }
  47.  
  48. Modal.propTypes = {
  49. onClose: PropTypes.func.isRequired,
  50. show: PropTypes.bool,
  51. children: PropTypes.node
  52. };
  53.  
  54. export default Modal;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement