refactor: update generic dialog to have title and maybe description
This commit is contained in:
1 parent
4fd11fbd1c
commit
f1d331cdf8
5 files changed
+44
-79
No files matched your search
@@ -1,10 +1,15 @@
|
|||||||
import { Modal, Stack } from "@mui/material";
|
import { useId } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
import { Modal, Stack, Typography } from "@mui/material";
|
||||||
|
|
||||||
const GenericDialog = ({ title, description, open, onClose, theme, children }) => {
|
const GenericDialog = ({ title, description, open, onClose, theme, children }) => {
|
||||||
|
const titleId = useId();
|
||||||
|
const descriptionId = useId();
|
||||||
|
const ariaDescribedBy = description?.length > 0 ? descriptionId : "";
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
aria-labelledby={title}
|
aria-labelledby={titleId}
|
||||||
aria-describedby={description}
|
aria-describedby={ariaDescribedBy}
|
||||||
open={open}
|
open={open}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
>
|
>
|
||||||
@@ -27,6 +32,23 @@ const GenericDialog = ({ title, description, open, onClose, theme, children }) =
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<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>
|
||||||
|
)}
|
||||||
{children}
|
{children}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -35,7 +57,7 @@ const GenericDialog = ({ title, description, open, onClose, theme, children }) =
|
|||||||
|
|
||||||
GenericDialog.propTypes = {
|
GenericDialog.propTypes = {
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.string.isRequired,
|
||||||
description: PropTypes.string.isRequired,
|
description: PropTypes.string,
|
||||||
open: PropTypes.bool.isRequired,
|
open: PropTypes.bool.isRequired,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
theme: PropTypes.object.isRequired,
|
theme: PropTypes.object.isRequired,
|
||||||
|
|||||||
@@ -1,46 +1,27 @@
|
|||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
|
||||||
import { Button, Stack, Typography } from "@mui/material";
|
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
|
import { Button, Stack } from "@mui/material";
|
||||||
import { GenericDialog } from "./genericDialog";
|
import { GenericDialog } from "./genericDialog";
|
||||||
import { useId } from "react";
|
|
||||||
const Dialog = ({
|
const Dialog = ({
|
||||||
|
title,
|
||||||
|
description,
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
theme,
|
theme,
|
||||||
title,
|
|
||||||
description,
|
|
||||||
onCancel,
|
onCancel,
|
||||||
confirmationButtonLabel,
|
confirmationButtonLabel,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
isLoading,
|
isLoading,
|
||||||
}) => {
|
}) => {
|
||||||
const titleId = useId();
|
|
||||||
const descriptionId = useId();
|
|
||||||
return (
|
return (
|
||||||
<GenericDialog
|
<GenericDialog
|
||||||
title={titleId}
|
title={title}
|
||||||
description={descriptionId}
|
description={description}
|
||||||
open={open}
|
open={open}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
<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>
|
|
||||||
)}
|
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
gap={theme.spacing(4)}
|
gap={theme.spacing(4)}
|
||||||
@@ -68,11 +49,11 @@ const Dialog = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
Dialog.propTypes = {
|
Dialog.propTypes = {
|
||||||
|
title: PropTypes.string.isRequired,
|
||||||
|
description: PropTypes.string,
|
||||||
open: PropTypes.bool.isRequired,
|
open: PropTypes.bool.isRequired,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
theme: PropTypes.object.isRequired,
|
theme: PropTypes.object.isRequired,
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
description: PropTypes.string,
|
|
||||||
onCancel: PropTypes.func.isRequired,
|
onCancel: PropTypes.func.isRequired,
|
||||||
confirmationButtonLabel: PropTypes.string.isRequired,
|
confirmationButtonLabel: PropTypes.string.isRequired,
|
||||||
onConfirm: PropTypes.func.isRequired,
|
onConfirm: PropTypes.func.isRequired,
|
||||||
|
|||||||
@@ -387,19 +387,11 @@ const ProfilePanel = () => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<GenericDialog
|
<GenericDialog
|
||||||
title={"modal-update-picture"}
|
title={"Upload Image"}
|
||||||
description={"update-profile-picture"}
|
|
||||||
open={isModalOpen("picture")}
|
open={isModalOpen("picture")}
|
||||||
onClose={closePictureModal}
|
onClose={closePictureModal}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
<Typography
|
|
||||||
id="modal-update-picture"
|
|
||||||
component="h1"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
Upload Image
|
|
||||||
</Typography>
|
|
||||||
<ImageField
|
<ImageField
|
||||||
id="update-profile-picture"
|
id="update-profile-picture"
|
||||||
src={
|
src={
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import TabPanel from "@mui/lab/TabPanel";
|
import TabPanel from "@mui/lab/TabPanel";
|
||||||
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
|
import { Button, ButtonGroup, Stack, Typography } from "@mui/material";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import Field from "../../Inputs/Field";
|
import Field from "../../Inputs/Field";
|
||||||
import { credentials } from "../../../Validation/validation";
|
import { credentials } from "../../../Validation/validation";
|
||||||
@@ -330,31 +330,14 @@ const TeamPanel = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<GenericDialog
|
<GenericDialog
|
||||||
title={"modal-invite-member"}
|
title={"Invite new team member"}
|
||||||
description={"invite-member-to-team"}
|
description={
|
||||||
|
"When you add a new team member, they will get access to all monitors."
|
||||||
|
}
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={closeInviteModal}
|
onClose={closeInviteModal}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
<Box>
|
|
||||||
<Typography
|
|
||||||
id="modal-invite-member"
|
|
||||||
component="h1"
|
|
||||||
fontWeight={600}
|
|
||||||
fontColor={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
Invite new team member
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
id="invite-member-to-team"
|
|
||||||
component="p"
|
|
||||||
fontSize={13}
|
|
||||||
color={theme.palette.text.accent}
|
|
||||||
sx={{ mt: theme.spacing(1), mb: theme.spacing(4) }}
|
|
||||||
>
|
|
||||||
When you add a new team member, they will get access to all monitors.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Field
|
<Field
|
||||||
type="email"
|
type="email"
|
||||||
id="input-team-member"
|
id="input-team-member"
|
||||||
|
|||||||
@@ -445,26 +445,13 @@ const PageSpeedConfigure = () => {
|
|||||||
isLoading={buttonLoading}
|
isLoading={buttonLoading}
|
||||||
/>
|
/>
|
||||||
<GenericDialog
|
<GenericDialog
|
||||||
title={"modal-delete-pagespeed-monitor"}
|
title={"Do you really want to delete this monitor?"}
|
||||||
description={"delete-pagespeed-monitor-confirmation"}
|
description={"Once deleted, this monitor cannot be retrieved."}
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={() => setIsOpen(false)}
|
onClose={() => setIsOpen(false)}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
<Typography
|
{/* Make it dialog? */}
|
||||||
id="modal-delete-pagespeed-monitor"
|
|
||||||
component="h2"
|
|
||||||
variant="h2"
|
|
||||||
fontWeight={500}
|
|
||||||
>
|
|
||||||
Do you really want to delete this monitor?
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
id="delete-pagespeed-monitor-confirmation"
|
|
||||||
variant="body1"
|
|
||||||
>
|
|
||||||
Once deleted, this monitor cannot be retrieved.
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
gap={theme.spacing(4)}
|
gap={theme.spacing(4)}
|
||||||
|
|||||||
Reference in new issue
Block a user