Skip to content

Commit

Permalink
Introduce Modal Closing
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Jun 1, 2024
1 parent 3047017 commit 998affb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/modals/CreateVault.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const CreateVault: FC<{ onClose: () => void }> = ({ onClose }) => {
const { address } = useAccount();

return (
<Modal>
<Modal onCloseRequest={onClose}>
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
iaculis magna efficitur, ultricies mi sed, malesuada turpis.
Expand Down
21 changes: 17 additions & 4 deletions src/components/modals/modal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
import { FC, PropsWithChildren } from "react";

export const Modal: FC<PropsWithChildren> = ({ children }) => {
export const Modal: FC<
PropsWithChildren<{
dismissOnBgClick?: boolean;
onCloseRequest?: () => void;
}>
> = ({ children, onCloseRequest, dismissOnBgClick = true }) => {
return (
<div className="bg-background-disabled/25 fixed inset-0 z-50 overflow-y-auto backdrop-blur-sm">
<div className="flex justify-center px-4 py-12 md:py-32">
<div className="card w-full max-w-96 p-4">{children}</div>
<div className="fixed inset-0 z-50 overflow-y-auto">
<div
className="relative"
onClick={dismissOnBgClick ? onCloseRequest : undefined}
>
<div className="bg-background-disabled/25 absolute inset-0 -z-10 overflow-y-auto backdrop-blur-sm"></div>
<div className="z-10 flex justify-center px-4 py-12 md:py-32">
<div className="card w-full max-w-96 p-4">{children}</div>
</div>
</div>
</div>
);
Expand Down

0 comments on commit 998affb

Please sign in to comment.