export default function ThemeProvider({ children }: Props) {
const settings = useSettingsContext();
const presets = createPresets(settings.themeColorPresets);
const memoizedValue = useMemo(
() => ({
palette: {
...palette(settings.themeMode),
...presets.palette,
},
customShadows: {
...customShadows(settings.themeMode),
...presets.customShadows,
},
direction: settings.themeDirection,
shadows: shadows(settings.themeMode),
shape: { borderRadius: 8 },
typography,
}),
[settings.themeMode, settings.themeDirection, presets.palette, presets.customShadows]
);
const theme = createTheme(memoizedValue as ThemeOptions);
theme.components = componentsOverrides(theme);
return (
<MuiThemeProvider theme={theme}>
<RTL themeDirection={settings.themeDirection}>
<CssBaseline />
{children}
</RTL>
</MuiThemeProvider>
);
}