Skip to content

Commit a74d294

Browse files
authored
Merge pull request #16 from 0ctanium/main
2 parents 4d5490f + 41173de commit a74d294

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/mui.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React, { useMemo } from "react";
33
import type { ReactNode } from "react";
44
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";
66
import { createTheme, ThemeProvider as MuiThemeProvider } from "@mui/material/styles";
77
import { getColors } from "./lib/colors";
88
import { useIsDark } from "./lib/darkMode";
@@ -15,12 +15,16 @@ import defaultMuiShadows from "@mui/material/styles/shadows";
1515
import type { Shadows } from "@mui/material/styles";
1616
import { id } from "tsafe/id";
1717

18-
function createMuiDsfrTheme(params: { isDark: boolean }): MuiTheme {
18+
export interface MuiDsfrThemeParams {
19+
isDark: boolean;
20+
}
21+
22+
export function getMuiDsfrThemeOptions(params: MuiDsfrThemeParams): ThemeOptions {
1923
const { isDark } = params;
2024

2125
const { options, decisions } = getColors(isDark);
2226

23-
const muiTheme = createTheme({
27+
return {
2428
"shape": {
2529
"borderRadius": 0
2630
},
@@ -229,7 +233,13 @@ function createMuiDsfrTheme(params: { isDark: boolean }): MuiTheme {
229233
return nonTypedMuiComponents as any as {};
230234
})()
231235
}
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);
233243

234244
return muiTheme;
235245
}

0 commit comments

Comments
 (0)