Files
Checkmate/Client/src/Components/Dialog/genericDialog.jsx
T

67 lines
1.5 KiB
React
Raw Normal View History

import { useId } from "react";
2024-10-22 05:58:21 -04:00
import PropTypes from "prop-types";
import { Modal, Stack, Typography } from "@mui/material";
2024-10-22 05:58:21 -04:00
const GenericDialog = ({ title, description, open, onClose, theme, children }) => {
const titleId = useId();
const descriptionId = useId();
const ariaDescribedBy = description?.length > 0 ? descriptionId : "";
2024-10-22 05:58:21 -04:00
return (
<Modal
aria-labelledby={titleId}
aria-describedby={ariaDescribedBy}
2024-10-22 05:58:21 -04:00
open={open}
onClose={onClose}
>
<Stack
gap={theme.spacing(2)}
sx={{
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 400,
bgcolor: theme.palette.background.main,
border: 1,
borderColor: theme.palette.border.light,
borderRadius: theme.shape.borderRadius,
boxShadow: 24,
p: theme.spacing(15),
"&:focus": {
outline: "none",
},
}}
>
<Typography
id={titleId}
component="h2"
fontSize={16}
color={theme.palette.text.primary}
fontWeight={600}
>
{title}
</Typography>
{description && (
<Typography
id={descriptionId}
color={theme.palette.text.tertiary}
>
{description}
</Typography>
)}
2024-10-22 05:58:21 -04:00
{children}
</Stack>
</Modal>
);
};
GenericDialog.propTypes = {
title: PropTypes.string.isRequired,
description: PropTypes.string,
2024-10-22 05:58:21 -04:00
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
theme: PropTypes.object.isRequired,
children: PropTypes.element.isRequired,
};
export { GenericDialog };