1
1
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" ;
4
3
import { colors } from "theme/colors" ;
5
- import { combineClasses } from "utils/combineClasses" ;
6
4
import {
7
5
LoadingButton ,
8
6
LoadingButtonProps ,
9
7
} from "../LoadingButton/LoadingButton" ;
10
8
import { ConfirmDialogType } from "./types" ;
9
+ import { type Interpolation , type Theme } from "@emotion/react" ;
11
10
12
11
export interface DialogActionButtonsProps {
13
12
/** Text to display in the cancel button */
14
13
cancelText ?: string ;
15
14
/** Text to display in the confirm button */
16
- confirmText ?: React . ReactNode ;
15
+ confirmText ?: ReactNode ;
17
16
/** Whether or not confirm is loading, also disables cancel when true */
18
17
confirmLoading ?: boolean ;
19
18
/** Whether or not this is a confirm dialog */
@@ -46,8 +45,6 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
46
45
onConfirm,
47
46
type = "info" ,
48
47
} ) => {
49
- const styles = useButtonStyles ( { type } ) ;
50
-
51
48
return (
52
49
< >
53
50
{ onCancel && (
@@ -65,10 +62,10 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
65
62
loading = { confirmLoading }
66
63
disabled = { disabled }
67
64
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
+ ] }
72
69
>
73
70
{ confirmText }
74
71
</ LoadingButton >
@@ -77,8 +74,8 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
77
74
) ;
78
75
} ;
79
76
80
- const useButtonStyles = makeStyles ( ( theme ) => ( {
81
- errorButton : {
77
+ const styles = {
78
+ errorButton : ( theme ) => ( {
82
79
"&.MuiButton-contained" : {
83
80
backgroundColor : colors . red [ 10 ] ,
84
81
borderColor : colors . red [ 9 ] ,
@@ -95,8 +92,8 @@ const useButtonStyles = makeStyles((theme) => ({
95
92
color : colors . red [ 9 ] ,
96
93
} ,
97
94
} ,
98
- } ,
99
- successButton : {
95
+ } ) ,
96
+ successButton : ( theme ) => ( {
100
97
"&.MuiButton-contained" : {
101
98
backgroundColor : theme . palette . success . main ,
102
99
color : theme . palette . primary . contrastText ,
@@ -145,8 +142,8 @@ const useButtonStyles = makeStyles((theme) => ({
145
142
color : theme . palette . text . secondary ,
146
143
} ,
147
144
} ,
148
- } ,
149
- } ) ) ;
145
+ } ) ,
146
+ } satisfies Record < string , Interpolation < Theme > > ;
150
147
151
148
export type DialogProps = MuiDialogProps ;
152
149
0 commit comments