Files
ohif-viewer/platform/ui/src/components/ohifModal/OHIFModal.js
T

81 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-11-04 12:55:05 -03:00
import React from 'react';
import PropTypes from 'prop-types';
2019-11-19 16:17:33 -03:00
import Modal from 'react-modal';
2019-11-04 12:55:05 -03:00
import classNames from 'classnames';
2019-11-19 16:17:33 -03:00
import './OHIFModal.styl';
const customStyle = {
overlay: {
zIndex: 1071,
backgroundColor: 'rgb(0, 0, 0, 0.5)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
};
Modal.setAppElement(document.getElementById('root'));
2019-11-04 12:55:05 -03:00
const OHIFModal = ({
className,
closeButton,
2019-11-19 16:17:33 -03:00
shouldCloseOnEsc,
isOpen,
fullscreen,
2019-11-04 12:55:05 -03:00
title,
2019-11-19 16:17:33 -03:00
onClose,
2019-11-14 17:40:37 -03:00
children,
2019-11-19 16:17:33 -03:00
}) => {
const renderHeader = () => {
return (
title && (
2019-12-11 13:46:10 -03:00
<div className="OHIFModal__header" data-cy="modal-header">
2019-11-19 16:17:33 -03:00
<h4>{title}</h4>
{closeButton && (
<button data-cy="close-button" onClick={onClose}>
×
</button>
)}
</div>
)
);
};
const classes = fullscreen
? classNames('OHIFModal', className, 'OHIFModal-fullscreen')
: classNames('OHIFModal', className);
2019-11-19 16:17:33 -03:00
return (
<Modal
className={classes}
2019-12-11 13:46:10 -03:00
data-cy="modal"
2019-11-19 16:17:33 -03:00
shouldCloseOnEsc={shouldCloseOnEsc}
isOpen={isOpen}
title={title}
style={customStyle}
>
<>
{renderHeader()}
2019-12-11 13:46:10 -03:00
<div className="OHIFModal__content" data-cy="modal-content">
{children}
</div>
2019-11-19 16:17:33 -03:00
</>
</Modal>
);
};
2019-11-04 12:55:05 -03:00
OHIFModal.propTypes = {
className: PropTypes.string,
closeButton: PropTypes.bool,
2019-11-19 16:17:33 -03:00
shouldCloseOnEsc: PropTypes.bool,
isOpen: PropTypes.bool,
2019-11-04 12:55:05 -03:00
title: PropTypes.string,
2019-11-19 16:17:33 -03:00
onClose: PropTypes.func,
2019-11-14 11:42:25 -03:00
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]).isRequired,
2019-11-04 12:55:05 -03:00
};
export default OHIFModal;