Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 3x 3x 2x 1x | import React, {Component} from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
export default class StatelessModal extends Component {
static propTypes = {
isOpen: PropTypes.bool,
onBackgroundClick: PropTypes.func,
className: PropTypes.string,
children: PropTypes.node,
}
static defaultProps = {
isOpen: false,
}
onBackgroundClick = (e) => {
Eif (this.props.onBackgroundClick) {
this.props.onBackgroundClick(e)
}
}
render() {
const className = classNames(this.props.className, {
'rev-Modal': true,
})
if (this.props.isOpen) {
return (
<div className={className}>
<div
role="button"
className="rev-Modal-background"
onClick={this.onBackgroundClick}
onKeyPress={this.onBackgroundClick}
tabIndex={0}
/>
<div className="rev-Modal-content">{this.props.children}</div>
</div>
)
}
return null
}
}
|