1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-06-30 20:23:59 +00:00

Add option to make modal scrollable.

This commit is contained in:
Bogdan Bodnar 2020-02-26 11:44:52 +01:00
parent 70da1c3c00
commit ba772be869
No known key found for this signature in database
GPG Key ID: 49E4169AD3CA42B0

View File

@ -17,6 +17,7 @@ Modal.propTypes = {
shown: PropTypes.bool.isRequired,
/** Callback to manage modal visibility */
setShown: PropTypes.func.isRequired,
scrollable: PropTypes.bool,
/** Modal content use following: `ModalHeader`, `ModalBody`, `ModalFooter` */
children: PropTypes.oneOfType([
@ -25,7 +26,9 @@ Modal.propTypes = {
]).isRequired,
};
export function Modal({ shown, setShown, children }) {
export function Modal({
shown, setShown, scrollable, children,
}) {
const dialogRef = useRef();
useClickOutside(dialogRef, () => setShown(false));
@ -33,7 +36,11 @@ export function Modal({ shown, setShown, children }) {
return (
<Portal containerId="modal-container">
<div className={`modal fade ${shown ? "show" : ""}`} role="dialog">
<div ref={dialogRef} className="modal-dialog modal-dialog-centered" role="document">
<div
ref={dialogRef}
className={`modal-dialog modal-dialog-centered${scrollable ? " modal-dialog-scrollable" : ""}`}
role="document"
>
<div className="modal-content">
{children}
</div>