From c925b533f6f9aec98560abd6236184d03a898e58 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Mon, 27 Nov 2023 11:31:13 +0800 Subject: [PATCH] fix: use flex center to get rid of modal blur --- packages/components/src/modal/modal.tsx | 76 +++++++++++---------- packages/components/src/modal/styles.css.ts | 15 ++-- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/packages/components/src/modal/modal.tsx b/packages/components/src/modal/modal.tsx index a926f45..4ddcd96 100644 --- a/packages/components/src/modal/modal.tsx +++ b/packages/components/src/modal/modal.tsx @@ -40,7 +40,7 @@ export const Modal = forwardRef( { width, height, - minHeight=194, + minHeight = 194, title, description, withoutCloseButton = false, @@ -67,42 +67,46 @@ export const Modal = forwardRef( className={clsx(styles.modalOverlay, overlayClassName)} {...otherOverlayOptions} /> - - {withoutCloseButton ? null : ( - - - - - - )} - {title ? ( - {title} - ) : null} - {description ? ( - - {description} - - ) : null} +
+ + {withoutCloseButton ? null : ( + + + + + + )} + {title ? ( + + {title} + + ) : null} + {description ? ( + + {description} + + ) : null} - {children} - + {children} + +
) diff --git a/packages/components/src/modal/styles.css.ts b/packages/components/src/modal/styles.css.ts index f5e6ef1..116e9c1 100644 --- a/packages/components/src/modal/styles.css.ts +++ b/packages/components/src/modal/styles.css.ts @@ -11,6 +11,15 @@ export const modalOverlay = style({ zIndex: 'var(--affine-z-index-modal)', }); +export const modalContentWrapper = style({ + position: 'fixed', + inset: 0, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + zIndex: 'var(--affine-z-index-modal)', +}); + export const modalContent = style({ vars: { [widthVar]: '', @@ -25,17 +34,13 @@ export const modalContent = style({ fontWeight: '400', lineHeight: '1.6', padding: '20px 24px', + position: 'relative', backgroundColor: 'var(--affine-background-overlay-panel-color)', boxShadow: 'var(--affine-popover-shadow)', borderRadius: '12px', maxHeight: 'calc(100vh - 32px)', // :focus-visible will set outline outline: 'none', - position: 'fixed', - zIndex: 'var(--affine-z-index-modal)', - top: ' 50%', - left: '50%', - transform: 'translate(-50%, -50%)', }); export const closeButton = style({