Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Upgrade HeadlessUI, new chart tests #1142

Merged
merged 6 commits into from
Dec 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: dialog
  • Loading branch information
severinlandolt committed Dec 6, 2024
commit 866d578c079a34f1b4193dac3b72e607cb920e03
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");
@@ -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>
);
});
2 changes: 1 addition & 1 deletion src/tests/layout-elements/Dialog.test.tsx
Original file line number Diff line number Diff line change
@@ -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>,
);