mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 10:23:54 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { Dialog as BaseDialog } from '@base-ui/react/dialog';
|
|
import type { ReactNode } from 'react';
|
|
import { IoClose } from 'react-icons/io5';
|
|
|
|
import IconButton from '../buttons/IconButton';
|
|
|
|
import style from './Dialog.module.scss';
|
|
|
|
interface DialogProps {
|
|
isOpen: boolean;
|
|
title: string;
|
|
showCloseButton?: boolean;
|
|
showBackdrop?: boolean;
|
|
bodyElements: ReactNode;
|
|
footerElements?: ReactNode;
|
|
onClose: () => void;
|
|
}
|
|
|
|
export default function Dialog({
|
|
isOpen,
|
|
title,
|
|
showCloseButton,
|
|
showBackdrop,
|
|
bodyElements,
|
|
footerElements,
|
|
onClose,
|
|
}: DialogProps) {
|
|
return (
|
|
<BaseDialog.Root
|
|
open={isOpen}
|
|
onOpenChange={(isOpen) => {
|
|
if (!isOpen) onClose();
|
|
}}
|
|
>
|
|
<BaseDialog.Portal>
|
|
{showBackdrop && <BaseDialog.Backdrop className={style.backdrop} />}
|
|
<BaseDialog.Popup className={style.dialog}>
|
|
<div className={style.title}>
|
|
{title}
|
|
{showCloseButton && (
|
|
<IconButton variant='subtle-white' onClick={onClose}>
|
|
<IoClose />
|
|
</IconButton>
|
|
)}
|
|
</div>
|
|
<div className={style.body}>{bodyElements}</div>
|
|
<div className={style.footer}>{footerElements}</div>
|
|
</BaseDialog.Popup>
|
|
</BaseDialog.Portal>
|
|
</BaseDialog.Root>
|
|
);
|
|
}
|