Keep modal heading margin only when close button is shown

[MAILPOET-2777]
This commit is contained in:
Jan Jakeš
2020-06-01 16:10:00 +02:00
committed by Veljko V
parent 954de9584e
commit 88a6e501a3
3 changed files with 5 additions and 1 deletions

View File

@@ -59,7 +59,7 @@
top: 0; top: 0;
z-index: $modal-header-z-index; z-index: $modal-header-z-index;
h3 { .mailpoet-modal-is-dismissible & h3 {
margin-right: $modal-close-button-size + $grid-gap; margin-right: $modal-close-button-size + $grid-gap;
} }
} }

View File

@@ -31,6 +31,7 @@ function Modal({
}: Props) { }: Props) {
return createPortal( return createPortal(
<ModalOverlay <ModalOverlay
isDismissible={isDismissible}
onRequestClose={onRequestClose} onRequestClose={onRequestClose}
shouldCloseOnEsc={shouldCloseOnEsc} shouldCloseOnEsc={shouldCloseOnEsc}
shouldCloseOnClickOutside={shouldCloseOnClickOutside} shouldCloseOnClickOutside={shouldCloseOnClickOutside}

View File

@@ -4,6 +4,7 @@ import classnames from 'classnames';
const ESCAPE = 27; const ESCAPE = 27;
type Props = { type Props = {
isDismissible?: boolean,
shouldCloseOnEsc?: boolean, shouldCloseOnEsc?: boolean,
shouldCloseOnClickOutside?: boolean, shouldCloseOnClickOutside?: boolean,
onRequestClose?: (event: React.SyntheticEvent) => void, onRequestClose?: (event: React.SyntheticEvent) => void,
@@ -12,6 +13,7 @@ type Props = {
}; };
function ModalOverlay({ function ModalOverlay({
isDismissible = true,
shouldCloseOnEsc = true, shouldCloseOnEsc = true,
shouldCloseOnClickOutside = true, shouldCloseOnClickOutside = true,
onRequestClose = () => {}, onRequestClose = () => {},
@@ -56,6 +58,7 @@ function ModalOverlay({
ref={overlayRef} ref={overlayRef}
className={classnames( className={classnames(
'mailpoet-modal-screen-overlay', 'mailpoet-modal-screen-overlay',
isDismissible ? 'mailpoet-modal-is-dismissible' : null,
className className
)} )}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}