Skip to content

Commit

Permalink
feat(Modal): allow passing z-index to overlay and modal
Browse files Browse the repository at this point in the history
  • Loading branch information
YossiSaadi committed Dec 18, 2024
1 parent 0855390 commit 13d3d12
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/components/Modal/Modal/Modal.module.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
$modal-default-z-index: 10000;

.overlay {
--monday-modal-z-index: 10000;
position: fixed;
inset: 0;
background-color: var(--color-surface);
z-index: var(--monday-modal-z-index);
z-index: var(--monday-modal-z-index, $modal-default-z-index);
}

.modal {
--monday-modal-z-index: 10000;
--top-actions-spacing: var(--spacing-large);
--top-actions-width: var(--spacing-xl);
--modal-inline-padding: var(--spacing-xl);

position: fixed;
top: 50%;
left: 50%;
z-index: var(--monday-modal-z-index);
z-index: var(--monday-modal-z-index, $modal-default-z-index);

display: flex;
flex-direction: column;
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/components/Modal/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const Modal = forwardRef(
container = document.body,
children,
style,
zIndex,
className,
"data-testid": dataTestId
}: ModalProps,
Expand Down Expand Up @@ -88,6 +89,9 @@ const Modal = forwardRef(
? modalAnimationAnchorPopVariants
: modalAnimationCenterPopVariants;

const zIndexStyle = zIndex ? ({ "--monday-modal-z-index": zIndex } as React.CSSProperties) : {};
const modalStyle = { ...zIndexStyle, ...style };

return (
<AnimatePresence>
{show && (
Expand All @@ -105,6 +109,7 @@ const Modal = forwardRef(
className={styles.overlay}
onClick={onBackdropClick}
aria-hidden
style={zIndexStyle}
/>
<FocusLock returnFocus>
<RemoveScroll forwardProps>
Expand All @@ -127,7 +132,7 @@ const Modal = forwardRef(
aria-modal
aria-labelledby={titleId}
aria-describedby={descriptionId}
style={style}
style={modalStyle}
>
{children}
<ModalTopActions
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/components/Modal/Modal/Modal.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ export interface ModalProps extends VibeComponentProps {
* Additional inline styles for the modal.
*/
style?: React.CSSProperties;
/**
* The z-index to be used for the modal and overlay.
*/
zIndex?: number;
}

0 comments on commit 13d3d12

Please sign in to comment.