{"size": 862, "ext": "js", "max_stars_repo_path": "src/components/modal/index.js", "max_stars_repo_name": "yandan66/skill-improve", "max_stars_repo_stars_event_min_datetime": "2020-07-29T03:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-29T03:39:55.000Z", "max_issues_repo_path": "src/components/modal/index.js", "max_issues_repo_name": "yandan66/skill-improve", "max_issues_repo_issues_event_min_datetime": "2021-08-31T20:17:43.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T08:50:32.000Z", "max_forks_repo_path": "src/components/modal/index.js", "max_forks_repo_name": "santa955/node-react-webpack-kit", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 23.9444444444, "max_line_length": 67, "alphanum_fraction": 0.6519721578}
import React from 'react'
import classNames from 'classnames/bind'
import PropTypes from 'prop-types'
import ModalPortal from './modal-portal'
import styles from './styles.styl'

const cx = classNames.bind(styles)

export default class Modal extends React.PureComponent {
  static defaultProps = {
    visible: false,
    width: 480,
    onOk: null,
    onCancel: null
  }

  static propTypes = {
    visible: PropTypes.bool.isRequired,
    width: PropTypes.number,
    onOk: PropTypes.func,
    onCancel: PropTypes.func.isRequired
  }

  render() {
    let { visible, width, onCancel, children } = this.props

    return (
      <ModalPortal visible={visible}>
        <div className={cx('modal-mask')} onClick={onCancel}></div>
        <div className={cx('modal-wrapper')} style={{ width }}>
          {children}
        </div>
      </ModalPortal>
    )
  }
}