22
33/* eslint-disable @typescript-eslint/no-non-null-assertion */
44import React , { useMemo , type ReactNode } from "react" ;
5- import { breakpointValues } from "./fr/generatedFromCss/breakpoints" ;
65import type { Theme as MuiTheme , ThemeOptions } from "@mui/material/styles" ;
76import { createTheme , ThemeProvider as MuiThemeProvider } from "@mui/material/styles" ;
87import type { Shadows } from "@mui/material/styles" ;
@@ -14,9 +13,13 @@ import { spacingTokenByValue } from "./fr/generatedFromCss/spacing";
1413import { assert } from "tsafe/assert" ;
1514import { objectKeys } from "tsafe/objectKeys" ;
1615import { id } from "tsafe/id" ;
16+ import { useBreakpointsValues , type BreakpointsValues } from "./useBreakpointsValues" ;
1717
18- export function getMuiDsfrThemeOptions ( params : { isDark : boolean } ) : ThemeOptions {
19- const { isDark } = params ;
18+ export function getMuiDsfrThemeOptions ( params : {
19+ isDark : boolean ;
20+ breakpointsValues : BreakpointsValues ;
21+ } ) : ThemeOptions {
22+ const { isDark, breakpointsValues } = params ;
2023
2124 const { options, decisions } = getColors ( isDark ) ;
2225
@@ -25,11 +28,9 @@ export function getMuiDsfrThemeOptions(params: { isDark: boolean }): ThemeOption
2528 "borderRadius" : 0
2629 } ,
2730 "breakpoints" : {
28- //"unit": breakpointValuesUnit,
31+ //NOTE: We would use "unit": breakpointsValuesUnit but only "px" works.
2932 "unit" : "px" ,
30- "values" : Object . fromEntries (
31- Object . entries ( breakpointValues ) . map ( ( [ key , value ] ) => [ key , value * 16 ] )
32- ) as any
33+ "values" : breakpointsValues
3334 } ,
3435 "palette" : {
3536 "mode" : isDark ? "dark" : "light" ,
@@ -244,7 +245,10 @@ export function getMuiDsfrThemeOptions(params: { isDark: boolean }): ThemeOption
244245 *
245246 * @returns — A complete, ready-to-use mui theme object.
246247 */
247- export function createMuiDsfrTheme ( params : { isDark : boolean } , ...args : object [ ] ) : MuiTheme {
248+ export function createMuiDsfrTheme (
249+ params : { isDark : boolean ; breakpointsValues : BreakpointsValues } ,
250+ ...args : object [ ]
251+ ) : MuiTheme {
248252 const muiTheme = createTheme ( getMuiDsfrThemeOptions ( params ) , ...args ) ;
249253
250254 return muiTheme ;
@@ -273,8 +277,10 @@ export function createMuiDsfrThemeProvider(params: {
273277
274278 const { isDark } = useIsDark_props ( ) ;
275279
280+ const { breakpointsValues } = useBreakpointsValues ( ) ;
281+
276282 const theme = useMemo ( ( ) => {
277- const nonAugmentedMuiTheme = createMuiDsfrTheme ( { isDark } ) ;
283+ const nonAugmentedMuiTheme = createMuiDsfrTheme ( { isDark, breakpointsValues } ) ;
278284
279285 return augmentMuiTheme === undefined
280286 ? nonAugmentedMuiTheme
0 commit comments