-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[styles] makeStyles + @media + Adapting based on props: not updating correctly #20446
Comments
Here are other 2 versions of function at the CSS property level (it works)
function at the selector level (it does not work)
|
MaterialUI So for what is worth, I also tested this directly using |
I found this case also. https://codesandbox.io/s/mutable-dawn-xyhub?file=/src/App.js const useStyles = makeStyles({
// root: ({ checked }) => {
// return {
// "& + span": {
// color: "red"
// },
// "& $text": {
// color: checked ? "blue" : "orange"
// }
// };
// },
root: {
"& $text": {
color: "purple"
}
},
text: {}
}); The current root works, but if you remove the comment section and remove existing root, text color won't change based on props |
An update, this issue is being resolved in v5 thanks to #22342 and the new |
@oliviertassinari Awesome! Will this also be resolved with v5, by chance? As a side question, why did you guys decide on |
@mkhoussid #15511 should be solved too. You can find the reasoning for emotion over styled-components in #22342, fundamentally, we think (after studying them in-depth) that the concepts API of styled components are better implemented. |
An update, we have now made enough progress with the new
This was made possible by the awesome work of @mnajdova. |
Current Behavior 😯
When a property is changed, styles that are inside a
@media
selector are not being re-generated.Expected Behavior 🤔
When a property is changed, all styles that are properties-dependent should be re-generated and re-applied to the component.
Steps to Reproduce 🕹
See example here: https://codesandbox.io/s/makestyles-mediaqueries-mygqi?file=/demo.js
Steps:
Context 🔦
I want to modify dynamically the fontSize of the input components (input, label, helper text) based on props.
I'm receiving a custom property called
size
that could be eitherLarge
orSmall
, and changing sizes of the components based on that property.The fontSize is expected to be responsive too, so for example
I need to access the props at the rule level because I'm generating the
@media
selectors in another utility that I can't modifyYour Environment 🌎
The text was updated successfully, but these errors were encountered: