1
1
import { colors } from "./colors"
2
2
import { ThemeOptions , createTheme , Theme } from "@mui/material/styles"
3
- import { BODY_FONT_FAMILY , borderRadius , borderRadiusSm } from "./constants"
3
+ import { BODY_FONT_FAMILY , borderRadius } from "./constants"
4
+
5
+ // MUI does not have aligned heights for buttons and inputs so we have to "hack" it a little bit
6
+ const INPUT_HEIGHT = 46
7
+ const BUTTON_LG_HEIGHT = 46
4
8
5
9
export type PaletteIndex = keyof Theme [ "palette" ]
6
10
export type PaletteStatusIndex = Extract <
@@ -55,6 +59,9 @@ export let dark = createTheme({
55
59
action : {
56
60
hover : colors . gray [ 14 ] ,
57
61
} ,
62
+ neutral : {
63
+ main : colors . gray [ 1 ] ,
64
+ } ,
58
65
} ,
59
66
typography : {
60
67
fontFamily : BODY_FONT_FAMILY ,
@@ -125,23 +132,22 @@ export let dark = createTheme({
125
132
letterSpacing : 1.5 ,
126
133
} ,
127
134
} ,
135
+ shape : {
136
+ borderRadius,
137
+ } ,
128
138
} )
129
139
130
140
dark = createTheme ( dark , {
131
141
components : {
132
142
MuiCssBaseline : {
133
- styleOverrides : {
134
- "@global" : {
135
- body : {
136
- backgroundImage : `linear-gradient(to right bottom, ${ dark . palette . background . default } , ${ colors . gray [ 17 ] } )` ,
137
- backgroundRepeat : "no-repeat" ,
138
- backgroundAttachment : "fixed" ,
139
- } ,
140
- ":root" : {
141
- colorScheme : dark . palette . mode ,
142
- } ,
143
- } ,
144
- } ,
143
+ styleOverrides : `
144
+ input:-webkit-autofill,
145
+ input:-webkit-autofill:hover,
146
+ input:-webkit-autofill:focus,
147
+ input:-webkit-autofill:active {
148
+ -webkit-box-shadow: 0 0 0 100px ${ dark . palette . background . default } inset !important;
149
+ }
150
+ ` ,
145
151
} ,
146
152
MuiAvatar : {
147
153
styleOverrides : {
@@ -166,78 +172,23 @@ dark = createTheme(dark, {
166
172
} ,
167
173
MuiButton : {
168
174
defaultProps : {
169
- variant : "contained" ,
175
+ variant : "outlined" ,
176
+ color : "neutral" ,
170
177
} ,
171
178
styleOverrides : {
172
- root : {
173
- // Prevents a loading button from collapsing!
174
- minHeight : 40 ,
175
- height : 40 , // Same size of input height
176
- fontWeight : "normal" ,
177
- fontSize : 16 ,
178
- textTransform : "none" ,
179
- letterSpacing : "none" ,
180
- border : `1px solid ${ dark . palette . divider } ` ,
181
- whiteSpace : "nowrap" ,
182
-
183
- "&:focus-visible" : {
184
- outline : `2px solid ${ dark . palette . primary . dark } ` ,
185
- } ,
186
- } ,
179
+ root : ( { ownerState } ) => {
180
+ let height : number | undefined = undefined
187
181
188
- contained : {
189
- boxShadow : "none" ,
190
- color : dark . palette . text . primary ,
191
- backgroundColor : colors . gray [ 13 ] ,
192
- borderColor : colors . gray [ 12 ] ,
182
+ if ( ownerState . size === "large" ) {
183
+ height = BUTTON_LG_HEIGHT
184
+ }
193
185
194
- "&:hover:not(:disabled):not(.MuiButton-containedPrimary):not(.MuiButton-containedSecondary)" :
195
- {
196
- boxShadow : "none" ,
197
- backgroundColor : colors . gray [ 12 ] ,
198
- borderColor : colors . gray [ 11 ] ,
199
- } ,
200
-
201
- "&.Mui-disabled:not(.MuiButton-containedPrimary):not(.MuiButton-containedSecondary)" :
202
- {
203
- color : colors . gray [ 9 ] ,
204
- backgroundColor : colors . gray [ 14 ] ,
205
- cursor : "not-allowed" ,
206
- pointerEvents : "auto" ,
207
- } ,
208
- } ,
209
- sizeSmall : {
210
- padding : `0 16px` ,
211
- fontSize : 14 ,
212
- minHeight : 36 ,
213
- height : 36 ,
214
- borderRadius : borderRadiusSm ,
215
- } ,
216
- iconSizeSmall : {
217
- width : 14 ,
218
- height : 14 ,
219
- marginLeft : "0 !important" ,
220
- marginRight : 8 ,
221
-
222
- "& svg:not(.MuiCircularProgress-svg)" : {
223
- width : 14 ,
224
- height : 14 ,
225
- } ,
226
- } ,
227
- outlined : {
228
- border : `1px solid ${ colors . gray [ 11 ] } ` ,
229
-
230
- "&:hover:not(:disabled)" : {
231
- borderColor : colors . gray [ 1 ] ,
232
- background : "none" ,
233
- } ,
234
-
235
- "&.Mui-disabled" : {
236
- color : colors . gray [ 9 ] ,
237
- border : `1px solid ${ colors . gray [ 12 ] } ` ,
238
- pointerEvents : "auto" ,
239
- cursor : "not-allowed" ,
240
- } ,
186
+ return {
187
+ height,
188
+ textTransform : "none" ,
189
+ letterSpacing : "normal" ,
190
+ fontWeight : 500 ,
191
+ }
241
192
} ,
242
193
} ,
243
194
} ,
@@ -310,30 +261,6 @@ dark = createTheme(dark, {
310
261
} ,
311
262
} ,
312
263
} ,
313
- MuiInputBase : {
314
- styleOverrides : {
315
- root : {
316
- borderRadius,
317
- } ,
318
- } ,
319
- } ,
320
- MuiOutlinedInput : {
321
- styleOverrides : {
322
- root : {
323
- "& .MuiOutlinedInput-notchedOutline" : {
324
- borderColor : dark . palette . divider ,
325
- } ,
326
-
327
- "& input:-webkit-autofill" : {
328
- WebkitBoxShadow : `0 0 0 1000px ${ dark . palette . background . paper } inset` ,
329
- } ,
330
-
331
- "&:hover:not(.Mui-focused) .MuiOutlinedInput-notchedOutline" : {
332
- borderColor : dark . palette . divider ,
333
- } ,
334
- } ,
335
- } ,
336
- } ,
337
264
MuiLink : {
338
265
styleOverrides : {
339
266
root : {
@@ -352,18 +279,6 @@ dark = createTheme(dark, {
352
279
} ,
353
280
} ,
354
281
} ,
355
- MuiFormHelperText : {
356
- styleOverrides : {
357
- contained : {
358
- marginLeft : 0 ,
359
- marginRight : 0 ,
360
- } ,
361
-
362
- marginDense : {
363
- marginTop : 8 ,
364
- } ,
365
- } ,
366
- } ,
367
282
MuiSkeleton : {
368
283
styleOverrides : {
369
284
root : {
@@ -434,15 +349,35 @@ dark = createTheme(dark, {
434
349
} ,
435
350
MuiTextField : {
436
351
defaultProps : {
437
- margin : "dense" ,
438
- variant : "outlined" ,
439
- spellCheck : false ,
352
+ InputLabelProps : {
353
+ shrink : true ,
354
+ } ,
440
355
} ,
441
356
} ,
442
- MuiFormControl : {
357
+ MuiInputBase : {
443
358
defaultProps : {
444
- variant : "outlined" ,
445
- margin : "dense" ,
359
+ color : "primary" ,
360
+ } ,
361
+ styleOverrides : {
362
+ root : ( { ownerState } ) => {
363
+ let height : number | undefined = undefined
364
+
365
+ if ( ownerState . size === "medium" ) {
366
+ height = INPUT_HEIGHT
367
+ }
368
+
369
+ return {
370
+ height,
371
+ }
372
+ } ,
373
+ } ,
374
+ } ,
375
+ MuiFormHelperText : {
376
+ defaultProps : {
377
+ sx : {
378
+ marginLeft : 0 ,
379
+ marginTop : 1 ,
380
+ } ,
446
381
} ,
447
382
} ,
448
383
MuiList : {
0 commit comments