UNPKG

frc-ui

Version:

React Web UI

39 lines (38 loc) 1.09 kB
import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; class Cover extends React.PureComponent { constructor() { super(...arguments); this.handleClick = (e) => { if (this.props.stopPrevent) { e.preventDefault(); const { onClick } = this.props; if (typeof onClick === 'function') { onClick(e); } } }; } render() { const { className, children, show } = this.props; const props = { className: classNames([className, 'frc-cover']), onClick: this.handleClick, style: { display: show ? '' : 'none' } }; return React.createElement("div", Object.assign({}, props), children); } } Cover.propTypes = { children: PropTypes.node, onClick: PropTypes.func, show: PropTypes.bool, className: PropTypes.string, stopPrevent: PropTypes.bool }; Cover.defaultProps = { show: false, stopPrevent: true }; export default Cover;