-
-
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
[system] transform and themeKey do not work together when using style from material-ui/system #23496
Comments
@cbravo Thanks for opening this issue, it's an interesting one. I'm doing a digression. We have recently revamped the documentation of the system in #23294. See before vs. after. In this move, we have put a lot of emphasis on the This made me think about how stitches as a createMuiTheme({
sx: {
spacing: (value) => ({
margin: -value * 8
})
},
});
<Box sx={{ spacing: 2 }} /> @cbravo Is being able to cherry-pick the different style transformations important for you? Meaning, would the above solution be enough or would you rather only add the transformations you need for a specific component? @mnajdova I wonder if, no matter what, we shouldn't add a page in the documentation around how to compose the style functions 1. to extend the sx prop with new behaviors, 2. to cherry-pick custom transformations. @cbravo Regarding your specific issue, it does sound like a bug and https://github.com/mui-org/material-ui/pull/16439/files#r300456428 seems to solve the issue. |
We can definitely add advanced section for going into details of how developers can extend these style functions. Will look into this particular issue when I will be working on it 👍 |
@oliviertassinari I will describe my exact use case in more detail: We have a two column layout that we use many repeated times on our website. Copy on the left or right with an image or video component on the other side for example. We were at first using a Grid but grid does not allow for a responsive spacing prop so I was hoping to use this functionality to create a component that would take So I think I would still need different style transformations on a component level. |
@oliviertassinari maybe... would the directionality along with the spacing of the stack be responsive? I would like my two-column layout to stack on vertically mobile but be horizontal row-reverse for desktop for example. And the ability to say I want the columns to be 50% 50% or 30% 60% split of the width on desktop. I also want to bake fading in from left or right for either column into my component but that is not really relevant other than to show I am looking to make a custom component for my specific repeating design pattern. This was the component I was looking to build for my current project and I figured the functionality we are talking about earlier using the style function would help me get there. |
@mnajdova The issue is all yours, I don't know what the next step should be, it could be closing, updating the docs, etc. |
I have looked at the upcoming roadmap you guys have... I am SO excited for what you have planned! there are so many good things coming. I am not sure where this leaves me in the mean time... for now unless you plan on merging that little fix I think I will have to find some work arounds until these new things get released. I hope you can take this comment as encouragement and to keep your motivation high! |
After going trough the comments, I think we should make two things:
diff --git a/packages/material-ui-system/src/style.js b/packages/material-ui-system/src/style.js
index 30fa2221f2..d495c74836 100644
--- a/packages/material-ui-system/src/style.js
+++ b/packages/material-ui-system/src/style.js
@@ -19,10 +19,10 @@ function getValue(themeMapping, transform, propValueFinal, userValue = propValue
value = themeMapping[propValueFinal] || userValue;
} else {
value = getPath(themeMapping, propValueFinal) || userValue;
+ }
- if (transform) {
- value = transform(value);
- }
+ if (transform) {
+ value = transform(value);
}
return value;
|
Can I take this one up? |
Using the material-ui system function 'style' does not work properly when used with theme and styled-components.
This is addressed in a closed PR (stale) that was never merged c9fdebb
with discussion here: https://github.com/mui-org/material-ui/pull/16439/files#diff-4d07c4a6e8c6006d5f726c3374e11607c23ba62024314e819983e3cfda099768R32-R35
I believe that this piece of the commit should be merged if possible
Current Behavior 😯
The transform function is never ran.
Expected Behavior 🤔
The transform function should run on my css value.
Steps to Reproduce 🕹
https://codesandbox.io/s/material-ui-issue-forked-61g88?file=/src/Demo.js
Sidenote: The latest official material-ui codesandbox is broken when using newest alpha version
Steps:
Context 🔦
I want to have the ability to apply a negative margin based on a spacing prop in order to achieve something similar to Mui Grid.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: