Skip to content

Commit

Permalink
fix: dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt committed Dec 6, 2024
1 parent 8fcee4c commit 866d578
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
26 changes: 7 additions & 19 deletions src/components/layout-elements/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Dialog as HeadlessuiDialog, Transition } from "@headlessui/react";
import { Dialog as HeadlessUiDialog, DialogBackdrop, Transition } from "@headlessui/react";
import { makeClassName, tremorTwMerge } from "lib";

const makeDisplayClassName = makeClassName("dialog");
Expand All @@ -17,31 +17,19 @@ const Dialog = React.forwardRef<HTMLDivElement, DialogProps>((props, ref) => {
const { children, className, ...other } = props;
return (
<Transition appear show={props.open}>
<HeadlessuiDialog
as="div"
<HeadlessUiDialog
ref={ref}
{...other}
className={tremorTwMerge(makeDisplayClassName("root"), "relative z-50", className)}
>
<Transition
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div
className={tremorTwMerge(
"fixed inset-0 bg-slate-950/30 dark:bg-slate-950/50 transition-opacity",
)}
></div>
</Transition>
<DialogBackdrop
transition
className="fixed bg-slate-950/30 dark:bg-slate-950/50 inset-0 transition-opacity data-[closed]:opacity-0 data-[enter]:duration-300 data-[leave]:duration-200 data-[enter]:ease-out data-[leave]:ease-in"
/>
<div className="fixed inset-0 overflow-y-auto w-screen">
<div className="flex min-h-full items-center justify-center p-4">{children}</div>
</div>
</HeadlessuiDialog>
</HeadlessUiDialog>
</Transition>
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/tests/layout-elements/Dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Dialog, DialogPanel } from "components";
describe("Dialog", () => {
test("renders the Dialog component", async () => {
const { findByText } = render(
<Dialog open onClose={() => {}}>
<Dialog open={true} onClose={() => {}} static={true}>
<DialogPanel>Test</DialogPanel>
</Dialog>,
);
Expand Down

0 comments on commit 866d578

Please sign in to comment.