From f522667ceeab69a4eda8ed3aeaae1f32370373d0 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Mon, 10 Jun 2024 11:52:37 -0300 Subject: [PATCH] Refactored BaseModal and fixed overflow that is hidden on various modals --- src/frontend/src/modals/IOModal/index.tsx | 4 +- src/frontend/src/modals/baseModal/index.tsx | 137 ++++++++++---------- 2 files changed, 67 insertions(+), 74 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index e047a3694..4bfb42025 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -183,8 +183,8 @@ export default function IOModal({ /> - -
+ +
= ({ children }) => { - return
{children}
; +const Content: React.FC = ({ children, overflowHidden }) => { + return ( +
+ {children} +
+ ); }; const Trigger: React.FC = ({ children, @@ -59,8 +68,12 @@ const Header: React.FC<{ }> = ({ children, description }: modalHeaderType): JSX.Element => { return ( - {children} - {description} + + {children} + + + {description} + ); }; @@ -75,27 +88,31 @@ const Footer: React.FC<{ dataTestId?: string; }; }> = ({ children, submit }) => { - return submit ? ( -
- {children ??
} -
- - - - -
+ return ( +
+ {submit ? ( +
+ {children ??
} +
+ + + + +
+
+ ) : ( + <>{children && children} + )}
- ) : ( - <>{children && children} ); }; interface BaseModalProps { @@ -159,71 +176,47 @@ function BaseModal({ } }, [open]); + const modalContent = useMemo( + () => ( + <> + {headerChild} + {ContentChild} + {ContentFooter && ContentFooter} + + ), + [headerChild, ContentChild, ContentFooter], + ); + + const contentClasses = cn( + minWidth, + height, + "flex flex-col duration-300 overflow-hidden", + ); + //UPDATE COLORS AND STYLE CLASSSES return ( <> {type === "modal" ? ( {triggerChild} - -
- {headerChild} -
-
- {ContentChild} -
- {ContentFooter && ( -
- {ContentFooter} -
- )} -
+ {modalContent}
) : ( {triggerChild} - -
- {headerChild} -
+ {onSubmit ? ( { event.preventDefault(); onSubmit(); }} - className="flex min-h-0 flex-1 flex-col gap-6" + asChild > -
- {ContentChild} -
- {ContentFooter && ( -
- {ContentFooter} -
- )} + {modalContent}
) : ( - <> -
- {ContentChild} -
- {ContentFooter && ( -
- {ContentFooter} -
- )} - + modalContent )}