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

[docs] Improve the CssBaseline description #16148

Merged
merged 4 commits into from
Jun 12, 2019
Merged

[docs] Improve the CssBaseline description #16148

merged 4 commits into from
Jun 12, 2019

Conversation

levigunz
Copy link
Contributor

Fixes bug in CssBaseline where spreading theme.typography.body2 attributes overwrites default body font colors (if they exist on body2 for some reason).

@mui-pr-bot
Copy link

mui-pr-bot commented Jun 11, 2019

No bundle size changes comparing 85058cc...7a40215

Generated by 🚫 dangerJS against 7a40215

@levigunz levigunz closed this Jun 11, 2019
@levigunz levigunz reopened this Jun 11, 2019
@eps1lon eps1lon changed the title [core] Moves body2 spread operator to top of body css [CssBaseline] Moves body2 spread operator to top of body css Jun 11, 2019
@eps1lon eps1lon added the component: CssBaseline The React component label Jun 11, 2019
Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Looks good. Though @oliviertassinari might have had a reason it was put in this specific place.

@eps1lon eps1lon requested a review from oliviertassinari June 11, 2019 06:40
@oliviertassinari
Copy link
Member

Could it explain why it's a but? I believe your typography color (none by default) should have priority over your palette color.

@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Jun 11, 2019
@oliviertassinari
Copy link
Member

I'm closing, the order is important.

@oliviertassinari

This comment has been minimized.

@eps1lon
Copy link
Member

eps1lon commented Jun 11, 2019

I'm closing, the order is important.

Could you add a test or explain why this is important? Current behavior is very opaque.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 11, 2019

The CssBaseline component should apply the theme.typography.body2 variant to the body of the page. It should be equivalent to use <Typography> (with the default variant).
Let's say you customize the color of theme.typography.body2. You want to see it replicated. Changing the order would be a breaking change and prevent the color to be applied.

We should update the documentation: https://material-ui.com/components/css-baseline/#typography.

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation and removed PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Jun 11, 2019
@levigunz
Copy link
Contributor Author

levigunz commented Jun 11, 2019

@oliviertassinari In the case I'm referencing the current order is a problem because it may cause unintended color side effects for header tags. They end up inheriting the now defined body color (from body2 in current implementation) instead of the text.primary color!

I would be under the belief that the text.primary should always have priority over body2 styles on the css body tag.

Correct me if I'm wrong, but then an implemented Typography element of type body2 would still overrule the body tag color because its definition is more specific!

@joshwooding
Copy link
Member

joshwooding commented Jun 11, 2019

Hmm, changing it might be a breaking change. I would expect body2 colours to override the primary text colour but I’m more than happy to be convinced otherwise. Looks like createTypography contains a unneeded comment though? https://github.com/mui-org/material-ui/blob/045dadc4609acb756adc74fcbf1a5150a054e14e/packages/material-ui/src/styles/createTypography.js#L36

Edit: I’m back to talking myself in circles. On one point I think it’s weird to have colours in typography declarations but I can see that they might be and they should overwrite if someone wants it to

@levigunz
Copy link
Contributor Author

@joshwooding It may come down to a matter of implementation opinion. I expected to be able to override the color of body2 individually, but still have my headings and other text inherit the text.primary color. In fact, that's how Material-UI functions until you include CssBaseline. Hence my confusion after adding CssBaseline to my project.

@oliviertassinari oliviertassinari changed the title [CssBaseline] Moves body2 spread operator to top of body css [docs] Improve the CssBaseline description Jun 11, 2019
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Thanks for providing the detail of your use case! I can imagine the confusion. Now, I believe that what you are describing is what we expect. in v4, we have changed the typography to be colorless by default. The color inherits for all the variants. The CssBaseline apply the body2 variant style so you can use this Typography component less frequently.

To solve your problem, I would probably extend the Typography to support a new color prop value or a new typography variant.

@eps1lon eps1lon merged commit 2c84a06 into mui:master Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: CssBaseline The React component docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants