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

Optional backdrop in slideover component #5821

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Changes from all commits
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
18 changes: 16 additions & 2 deletions src/CAREUI/interactive/SlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export type SlideOverProps = {
dialogClass?: string;
title?: React.ReactNode;
onlyChild?: boolean;
backdropBlur?: boolean;
closeOnBackdropClick?: boolean;
onCloseClick?: () => void;
};

Expand All @@ -24,6 +26,8 @@ export default function SlideOver({
dialogClass,
title,
onlyChild = false,
backdropBlur = true,
closeOnBackdropClick = true,
onCloseClick,
}: SlideOverProps) {
const directionClasses = {
Expand Down Expand Up @@ -55,7 +59,12 @@ export default function SlideOver({

return (
<Transition.Root show={open} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={setOpen}>
<Dialog
as="div"
className="relative z-10"
// eslint-disable-next-line @typescript-eslint/no-empty-function
onClose={closeOnBackdropClick ? setOpen : () => {}}
>
<Transition.Child
as={Fragment}
enter="ease-in-out duration-500"
Expand All @@ -65,7 +74,12 @@ export default function SlideOver({
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black/75 backdrop-blur-sm transition-all" />
<div
className={classNames(
"fixed transition-all",
backdropBlur && "bg-black/75 backdrop-blur-sm inset-0"
)}
/>
</Transition.Child>
<Transition.Child
as={Fragment}
Expand Down