Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui] Stabilize CssVarsProvider and extendTheme #42246

Merged
merged 17 commits into from
May 27, 2024

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented May 15, 2024

Changes

  • Add stable APIs without experimental prefix and replace all the usages in the repo
  • Add warning to experimental APIs
  • Move docs from "experimental" section to "customization" (I'd like to keep the structure the same in this PR, I have a plan to improve the content in a separate PR)

@siriwatknp siriwatknp added the docs Improvements or additions to the documentation label May 15, 2024
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few small comments, from technical point of view it looks good 👍

docs/data/material/customization/theming/theming.md Outdated Show resolved Hide resolved
@@ -4,7 +4,7 @@ import {
demos,
docs,
demoComponents,
} from 'docs/data/material/experimental-api/css-theme-variables/usage/usage.md?muiMarkdown';
} from 'docs/data/material/customization/css-theme-variables/customization.md?muiMarkdown';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this path name: /material/customization/foobar/customization just looks weird to me with customization repeated. I'm not sure which one really needs to be replaced but it seems like this doc file name is the simpler choice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 here, too — maybe this page could be called "Customizing CSS theme variables"? Then, drop the hyphen on the title!

Screenshot 2024-05-20 at 19 40 53

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to "configuration", is it better?

Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as Marija, technical changes look good to me

Good job carrying this through the finish line 🚀

@DiegoAndai
Copy link
Member

@siriwatknp this closes #41070 right?

Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 it!

@siriwatknp siriwatknp enabled auto-merge (squash) May 27, 2024 23:15
@siriwatknp siriwatknp merged commit 6cec270 into mui:next May 27, 2024
22 checks passed
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 8, 2024

What do you think about renaming extendTheme() to createCssVarsTheme(), so it's clear when compared to createTheme() what it is?

At this point, there is no reason not to move CSS variables all-in. Keeping a hybrid mode brings no value beyond allowing people to migrate. But even then it can very likely be done with barely any breaking changes. I mean, why would there be any? So I would deprecate createTheme() for createLegacyTheme() to free the namespace. And try to rename to createCssVarsTheme() to createTheme().

On the Pigment CSS, side, I think that we could already rename to createTheme(): mui/pigment-css#131.


On a different topic, looking at the source, I'm confused about the architecture. I would propose we create 7 issues, one for each:

Why don't we straight forward the theme id? Why do we check if the theme exists before forwarding it? I mean, wouldn't it be simpler and more predictable to have themeId={THEME_ID} here and in all the other places?

  • 2. Why do we have argument mutations?

themeProp.defaultColorScheme = resolvedDefaultColorScheme;

#41446 (comment)

Couldn't we remove those?

Could we remove all of this? Place them into a dedicated structure, or as arguments to the theme creator.

  • 4. Why do we have a colorSchemeSelector, attribute API in the first place when we have getSelector(). Isn't it a straight duplicate? Point 1 in The "getSelector" API feels strange pigment-css#128: couldn't we replace all of this with getColorSchemeSelector?

  • 5. Why is generateStyleSheets created when creating the extendTheme and not created by the CssVarProvider component?

  • 6. Why is generateThemeVars created when creating the extendTheme, not used to create the vars, but then used to recreate the vars again in CssVarProvider. Can we only do it once and in extendTheme?

  • 7. Why is resolveTheme called like this when it doesn't resolve the Theme ID but transfers the theme. Also, I don't understand why this exists in the first place. Shouldn't it be done in extendTheme, so theme.typography has correct values?

bharatkashyap pushed a commit to bharatkashyap/material-ui that referenced this pull request Jun 26, 2024
joserodolfofreitas pushed a commit to joserodolfofreitas/material-ui that referenced this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants