From 58d71a863bf419a5768ac33020c5d27f072516cb Mon Sep 17 00:00:00 2001 From: daniel31x13 Date: Wed, 1 May 2024 17:15:00 -0400 Subject: [PATCH] small improvement --- components/Modal.tsx | 41 ++++++++++++++++++++++++++--------------- pages/login.tsx | 9 ++++++--- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/components/Modal.tsx b/components/Modal.tsx index 1620b2c..4691df7 100644 --- a/components/Modal.tsx +++ b/components/Modal.tsx @@ -6,9 +6,15 @@ type Props = { toggleModal: Function; children: ReactNode; className?: string; + dismissible?: boolean; }; -export default function Modal({ toggleModal, className, children }: Props) { +export default function Modal({ + toggleModal, + className, + children, + dismissible = true, +}: Props) { const [drawerIsOpen, setDrawerIsOpen] = React.useState(true); useEffect(() => { @@ -26,14 +32,17 @@ export default function Modal({ toggleModal, className, children }: Props) { return ( setTimeout(() => toggleModal(), 100)} + onClose={() => dismissible && setTimeout(() => toggleModal(), 100)} + dismissible={dismissible} > - setDrawerIsOpen(false)}> - + dismissible && setDrawerIsOpen(false)} + > +
dismissible && toggleModal()} className={`w-full mt-auto sm:m-auto sm:w-11/12 sm:max-w-2xl ${ className || "" }`} @@ -64,15 +73,17 @@ export default function Modal({ toggleModal, className, children }: Props) { className="slide-up mt-auto sm:m-auto relative border-neutral-content rounded-t-2xl sm:rounded-2xl border-t sm:border shadow-2xl p-5 bg-base-100 overflow-y-auto sm:overflow-y-visible" data-testid="modal-container" > -
} - className="absolute top-4 right-3 btn btn-sm outline-none btn-circle btn-ghost z-10" - > - -
+ {dismissible && ( +
} + className="absolute top-4 right-3 btn btn-sm outline-none btn-circle btn-ghost z-10" + > + +
+ )} {children}
diff --git a/pages/login.tsx b/pages/login.tsx index 13941d1..1824afe 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -69,7 +69,7 @@ export default function Login({ function displayLoginCredential() { if (availableLogins.credentialsEnabled === "true") { return ( -
+ <>

Enter your credentials

@@ -127,7 +127,7 @@ export default function Login({ {availableLogins.buttonAuths.length > 0 ? (
OR
) : undefined} -
+ ); } } @@ -171,7 +171,10 @@ export default function Login({ return (
-
+
{displayLoginCredential()} {displayLoginExternalButton()} {displayRegistration()}