Skip to content

Commit c824abc

Browse files
committed
emotion: Dialog
1 parent 4407eda commit c824abc

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

site/src/components/Dialogs/Dialog.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import MuiDialog, { DialogProps as MuiDialogProps } from "@mui/material/Dialog";
2-
import { makeStyles } from "@mui/styles";
3-
import * as React from "react";
2+
import { type ReactNode } from "react";
43
import { colors } from "theme/colors";
5-
import { combineClasses } from "utils/combineClasses";
64
import {
75
LoadingButton,
86
LoadingButtonProps,
97
} from "../LoadingButton/LoadingButton";
108
import { ConfirmDialogType } from "./types";
9+
import { type Interpolation, type Theme } from "@emotion/react";
1110

1211
export interface DialogActionButtonsProps {
1312
/** Text to display in the cancel button */
1413
cancelText?: string;
1514
/** Text to display in the confirm button */
16-
confirmText?: React.ReactNode;
15+
confirmText?: ReactNode;
1716
/** Whether or not confirm is loading, also disables cancel when true */
1817
confirmLoading?: boolean;
1918
/** Whether or not this is a confirm dialog */
@@ -46,8 +45,6 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
4645
onConfirm,
4746
type = "info",
4847
}) => {
49-
const styles = useButtonStyles({ type });
50-
5148
return (
5249
<>
5350
{onCancel && (
@@ -65,10 +62,10 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
6562
loading={confirmLoading}
6663
disabled={disabled}
6764
type="submit"
68-
className={combineClasses({
69-
[styles.errorButton]: type === "delete",
70-
[styles.successButton]: type === "success",
71-
})}
65+
css={[
66+
type === "delete" && styles.errorButton,
67+
type === "success" && styles.successButton,
68+
]}
7269
>
7370
{confirmText}
7471
</LoadingButton>
@@ -77,8 +74,8 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
7774
);
7875
};
7976

80-
const useButtonStyles = makeStyles((theme) => ({
81-
errorButton: {
77+
const styles = {
78+
errorButton: (theme) => ({
8279
"&.MuiButton-contained": {
8380
backgroundColor: colors.red[10],
8481
borderColor: colors.red[9],
@@ -95,8 +92,8 @@ const useButtonStyles = makeStyles((theme) => ({
9592
color: colors.red[9],
9693
},
9794
},
98-
},
99-
successButton: {
95+
}),
96+
successButton: (theme) => ({
10097
"&.MuiButton-contained": {
10198
backgroundColor: theme.palette.success.main,
10299
color: theme.palette.primary.contrastText,
@@ -145,8 +142,8 @@ const useButtonStyles = makeStyles((theme) => ({
145142
color: theme.palette.text.secondary,
146143
},
147144
},
148-
},
149-
}));
145+
}),
146+
} satisfies Record<string, Interpolation<Theme>>;
150147

151148
export type DialogProps = MuiDialogProps;
152149

0 commit comments

Comments
 (0)