-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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] Allow CSS properties to be functions #15546
Conversation
No bundle size changes comparing 2e78390...4b05497 |
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.
Can you add TS demos for https://next.material-ui.com/css-in-js/basics/#adapting-the-styled-components-api and https://next.material-ui.com/css-in-js/basics/#adapting-the-higher-order-component-api as well?
Looks like this change is required for these to work. This would mean we have a test for the change.
Yes, though it's blocked by #15501 which is blocked by this PR. So the demos should probably be in their own PR |
2fb3172
to
1610226
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.
I don't think it has any impact whether we use object
or {}
as the base type for Props
. What object
tries to convey is that a plain object should be passed which we can't type check with TypeScript so we just communicate the requirement.
Rest looks awesome.
@eps1lon I noticed that core has it's own |
Right. I was wondering why this was working now (I thought I tried it before) but it only works because The problem is that there are just way to many overloads and for structural types it somehow breaks down because at some point the compiler doesn't know if it is themed based or props based. I somewhat gave up on typing every possible pattern. We support props based styling on the class key level which should cover most of the use cases. If you can make this work for the current test suite in |
Should we close the pull request, for now? |
4b05497
to
7e8cf7b
Compare
No bundle size changes comparing f246dbd...912b97f |
@eps1lon I didn't have time to look into this properly until now, but I think you're wrong here. As I didn't update |
About what? You can look at the repo and you can compare the amount of test in I'm not sure you're aware what is typed where currently i.e. core/styles/withStyles has a different definition compared to styles/withStyles which is why changing styles/withStyles doesn't cause breakage because it doesn't have the same tests as core/styles/withStyles. Until we can consolidate both definitions we shouldn't make changes to the implementations because we don't have a clear picture what is tested. |
@eps1lon You're right, my bad. Working on it now. |
@eps1lon That should do it |
81ac55e
to
63951fe
Compare
@eps1lon Requesting a review |
I'd like to consolidate the types and tests for mui/core and mui/core/styles first to have an overview if something is already broken between core/styles and styles. Then we can move forward. |
63951fe
to
80f483f
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.
Very nice. Took the liberty and named some remaining unnamed generic arguments when we expect a certain type. T, U etc only make sense for truly generic types e.g Pick, Omit
@eps1lon Since props is optional, that should keep it backwards compatible. Should we add a comment to switch it for V5? |
It's only a minor inconvenience/unelegant code. Nothing that warrants a breaking change in the future. Maybe that'll change. Let's leave this for now and see how it goes. |
Fixes #14814
Fixes #16007