-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Add array support for sx
prop
#29297
Conversation
This would be a breaking change, so we can't do it now. But we can wait to see if people will actually need it. I would say it's more common to add conditional styles based on where the component is being used, which means in the context of the parent component and developers anyway have access to those props :) |
if (!isPlainObject(result)) { | ||
return systemProps; | ||
} | ||
return { ...systemProps, ...result }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we do deep merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. That will cause a lot more calculation. I think it is better to document that sx has more priority.
<Box p={2} sx={{ p: 3 }} /> // p: 3 wins
Also, the previous implementation used { ...systemProps, ...result }
and there is no issue with it yet. So I don't think anyone will use the same property in both props & sx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, let's leave it as is then :)
8abd3f5
to
bde7da6
Compare
will run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
41cfc61
to
bde7da6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
close #29274
I noticed one thing from #29198. Shouldn't the sx function callback give the whole props (theme is inside the props)?
current
What I thinkstyled
sx
Decide to go with the current approach and see community feedback.
@mnajdova @hbjORbj