1
1
import MuiDialog , {
2
2
DialogProps as MuiDialogProps ,
3
3
} from "@material-ui/core/Dialog"
4
- import { alpha , darken , lighten , makeStyles } from "@material-ui/core/styles"
4
+ import { alpha , darken , makeStyles } from "@material-ui/core/styles"
5
5
import * as React from "react"
6
+ import { colors } from "theme/colors"
6
7
import { combineClasses } from "../../util/combineClasses"
7
8
import {
8
9
LoadingButton ,
@@ -42,7 +43,6 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
42
43
cancelText = "Cancel" ,
43
44
confirmText = "Confirm" ,
44
45
confirmLoading = false ,
45
- confirmDialog,
46
46
disabled = false ,
47
47
onCancel,
48
48
onConfirm,
@@ -54,29 +54,24 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
54
54
< >
55
55
{ onCancel && (
56
56
< LoadingButton
57
- className = { combineClasses ( {
58
- [ styles . dialogButton ] : true ,
59
- [ styles . cancelButton ] : true ,
60
- [ styles . confirmDialogCancelButton ] : confirmDialog ,
61
- } ) }
62
57
disabled = { confirmLoading }
63
58
onClick = { onCancel }
64
59
variant = "outlined"
60
+ fullWidth
65
61
>
66
62
{ cancelText }
67
63
</ LoadingButton >
68
64
) }
69
65
{ onConfirm && (
70
66
< LoadingButton
67
+ fullWidth
71
68
variant = "contained"
72
69
onClick = { onConfirm }
73
70
color = { typeToColor ( type ) }
74
71
loading = { confirmLoading }
75
72
disabled = { disabled }
76
73
type = "submit"
77
74
className = { combineClasses ( {
78
- [ styles . dialogButton ] : true ,
79
- [ styles . submitButton ] : true ,
80
75
[ styles . errorButton ] : type === "delete" ,
81
76
[ styles . successButton ] : type === "success" ,
82
77
} ) }
@@ -88,119 +83,17 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
88
83
)
89
84
}
90
85
91
- interface StyleProps {
92
- type : ConfirmDialogType
93
- }
94
-
95
86
const useButtonStyles = makeStyles ( ( theme ) => ( {
96
- dialogButton : {
97
- borderRadius : theme . shape . borderRadius ,
98
- fontSize : theme . typography . h6 . fontSize ,
99
- fontWeight : theme . typography . h5 . fontWeight ,
100
- padding : `${ theme . spacing ( 0.75 ) } px ${ theme . spacing ( 2 ) } px` ,
101
- width : "100%" ,
102
- boxShadow : "none" ,
103
- } ,
104
- cancelButton : {
105
- background : alpha ( theme . palette . primary . main , 0.1 ) ,
106
- color : theme . palette . primary . main ,
107
-
108
- "&:hover" : {
109
- background : alpha ( theme . palette . primary . main , 0.3 ) ,
110
- } ,
111
- } ,
112
- confirmDialogCancelButton : ( props : StyleProps ) => {
113
- const color =
114
- props . type === "info"
115
- ? theme . palette . primary . contrastText
116
- : theme . palette . error . contrastText
117
- return {
118
- background : alpha ( color , 0.15 ) ,
119
- color,
120
-
121
- "&:hover" : {
122
- background : alpha ( color , 0.3 ) ,
123
- } ,
124
-
125
- "&.Mui-disabled" : {
126
- background : alpha ( color , 0.15 ) ,
127
- color : alpha ( color , 0.5 ) ,
128
- } ,
129
- }
130
- } ,
131
- submitButton : {
132
- // Override disabled to keep background color, change loading spinner to contrast color
133
- "&.Mui-disabled" : {
134
- "&.MuiButton-containedPrimary" : {
135
- background : theme . palette . primary . dark ,
136
-
137
- "& .MuiCircularProgress-root" : {
138
- color : theme . palette . primary . contrastText ,
139
- } ,
140
- } ,
141
-
142
- "&.CdrButton-error.MuiButton-contained" : {
143
- background : darken ( theme . palette . error . main , 0.3 ) ,
144
-
145
- "& .MuiCircularProgress-root" : {
146
- color : theme . palette . error . contrastText ,
147
- } ,
148
- } ,
149
- } ,
150
- } ,
151
87
errorButton : {
152
88
"&.MuiButton-contained" : {
153
- backgroundColor : lighten ( theme . palette . error . dark , 0.15 ) ,
154
- color : theme . palette . error . contrastText ,
155
- "&:hover" : {
156
- backgroundColor : theme . palette . error . dark ,
157
- "@media (hover: none)" : {
158
- backgroundColor : "transparent" ,
159
- } ,
160
- "&.Mui-disabled" : {
161
- backgroundColor : "transparent" ,
162
- } ,
163
- } ,
164
- "&.Mui-disabled" : {
165
- backgroundColor : theme . palette . action . disabledBackground ,
166
- color : alpha ( theme . palette . text . disabled , 0.5 ) ,
167
- } ,
168
- } ,
169
-
170
- "&.MuiButton-outlined" : {
171
- color : theme . palette . error . main ,
172
- borderColor : theme . palette . error . main ,
173
- "&:hover" : {
174
- backgroundColor : alpha (
175
- theme . palette . error . main ,
176
- theme . palette . action . hoverOpacity ,
177
- ) ,
178
- "@media (hover: none)" : {
179
- backgroundColor : "transparent" ,
180
- } ,
181
- "&.Mui-disabled" : {
182
- backgroundColor : "transparent" ,
183
- } ,
184
- } ,
185
- "&.Mui-disabled" : {
186
- color : alpha ( theme . palette . text . disabled , 0.5 ) ,
187
- borderColor : theme . palette . action . disabled ,
188
- } ,
189
- } ,
190
-
191
- "&.MuiButton-text" : {
192
- color : theme . palette . error . main ,
89
+ backgroundColor : colors . red [ 10 ] ,
90
+ borderColor : colors . red [ 9 ] ,
91
+ color : theme . palette . text . primary ,
193
92
"&:hover" : {
194
- backgroundColor : alpha (
195
- theme . palette . error . main ,
196
- theme . palette . action . hoverOpacity ,
197
- ) ,
198
- "@media (hover: none)" : {
199
- backgroundColor : "transparent" ,
200
- } ,
93
+ backgroundColor : colors . red [ 9 ] ,
201
94
} ,
202
95
"&.Mui-disabled" : {
203
- color : alpha ( theme . palette . text . disabled , 0.5 ) ,
96
+ opacity : 0.5 ,
204
97
} ,
205
98
} ,
206
99
} ,
0 commit comments