1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-11-14 17:35:35 +01:00

Merge branch 'scrollable-modal' into 'dev'

Add option to make modal scrollable.

See merge request turris/reforis/foris-js!97
This commit is contained in:
Bogdan Bodnar 2020-02-26 11:47:50 +01:00
commit dbb840d51c

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>