2
2
import React , { useMemo } from "react" ;
3
3
import type { ReactNode } from "react" ;
4
4
import { breakpointValues , breakpointValuesUnit } from "./lib/generatedFromCss/breakpoints" ;
5
- import type { Theme as MuiTheme } from "@mui/material/styles" ;
5
+ import type { Theme as MuiTheme , ThemeOptions } from "@mui/material/styles" ;
6
6
import { createTheme , ThemeProvider as MuiThemeProvider } from "@mui/material/styles" ;
7
7
import { getColors } from "./lib/colors" ;
8
8
import { useIsDark } from "./lib/darkMode" ;
@@ -15,12 +15,16 @@ import defaultMuiShadows from "@mui/material/styles/shadows";
15
15
import type { Shadows } from "@mui/material/styles" ;
16
16
import { id } from "tsafe/id" ;
17
17
18
- function createMuiDsfrTheme ( params : { isDark : boolean } ) : MuiTheme {
18
+ export interface MuiDsfrThemeParams {
19
+ isDark : boolean ;
20
+ }
21
+
22
+ export function getMuiDsfrThemeOptions ( params : MuiDsfrThemeParams ) : ThemeOptions {
19
23
const { isDark } = params ;
20
24
21
25
const { options, decisions } = getColors ( isDark ) ;
22
26
23
- const muiTheme = createTheme ( {
27
+ return {
24
28
"shape" : {
25
29
"borderRadius" : 0
26
30
} ,
@@ -229,7 +233,13 @@ function createMuiDsfrTheme(params: { isDark: boolean }): MuiTheme {
229
233
return nonTypedMuiComponents as any as { } ;
230
234
} ) ( )
231
235
}
232
- } ) ;
236
+ } ;
237
+ }
238
+
239
+ export function createMuiDsfrTheme ( params : MuiDsfrThemeParams , ...args : object [ ] ) : MuiTheme {
240
+ const options = getMuiDsfrThemeOptions ( params ) ;
241
+
242
+ const muiTheme = createTheme ( options , ...args ) ;
233
243
234
244
return muiTheme ;
235
245
}
0 commit comments