codegouvfr / react-dsfr

🇫🇷 The French Government Design system React toolkit
https://react-dsfr.codegouv.studio
MIT License
417 stars 56 forks source link

Export 'createMuiDsfrTheme' function and allow theme options overriding #15

Closed 0ctanium closed 1 year ago

0ctanium commented 1 year ago

Only exposing the ThemeProvider is pretty constraining. If we are using a custom theme provider, are want to create a theme switcher, the DSFR Provider limits the functionality.

Could you please split up in more parts the theme creation in order to allow other to implement the theme in more controlled environments.

The default createTheme function allow overriding. See: https://mui.com/material-ui/customization/theming/#createtheme-options-args-theme

garronej commented 1 year ago

Ok thanks for the feedback,
Can do.
Are you aware of this customizability option: https://react-dsfr.etalab.studio/mui ?

0ctanium commented 1 year ago

Yes, but feeding it to a custom provider is kind of a big workaround.

I prefer generating the two theme options separately, and then merge them with the theme merge utility from MUI. I find it more practical when you want to override a deeply nested property.

Also, still having control over the provider allows to easily implement a theme switcher.

Great implementation anyway ;)

garronej commented 1 year ago

Ok make sence,

If you want to build your own theme switcher I assume that you are using @dataesr/react-dsfr.
I redacted a little section in the readme about what how the two libs can be used alongside each other.

Thanks for the contribution.