-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
[core] Remove makeStyles
dependency on @material-ui/core/styles
#1627
Conversation
This one is going to be interesting. Data grid supports v4 and v5, which add complexity to this effort. The best option I can think of is to have a implicit transitive dependency on @material-ui/styles and ask v5 users to install the package manually. Why? Because @material-ui/styles is a singleton, a duplication of package in the bundle would mean losing the theme which will be a mess to debug and handle as support requests. |
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.
Good luck with this one, it will require to make tradeoffs.
@@ -1,5 +1,5 @@ | |||
import * as React from 'react'; | |||
import { makeStyles } from '@material-ui/core/styles'; | |||
import { makeStyles } from '@material-ui/styles'; |
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.
This is the docs for v4, this change is borderline but it can fly. Alternatives are probably worse.
Don't have a better proposal either. Seems like the best compromised to make it work with both versions... I also think, that v5 users will need to install @oliviertassinari should we then list |
|
Also adding @DanailH as the last one to work on v4/v5 support. We would need to open the changes in codesandbox and test that v5 works too. |
docs/src/pages/components/data-grid/columns/RenderExpandCellGrid.tsx
Outdated
Show resolved
Hide resolved
@mnajdova let me know how I can help with this effort. If I understood the problem correctly it looks like we would need a wrapper like the |
Just pushed the change :D Let me know if it looks correct. I didn't change the docs/ and packages/storybook files, is that correct? |
Yes I don't think we need to change those since they are loaded under v4. |
@dtassone @DanailH this should be ready for review. Also, see discussion for the |
not sure I understand why there are 2 styles packages now import { createMuiTheme, Theme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles'; I would have expected. import { makeStyles, createMuiTheme, Theme } from '@material-ui/styles'; |
The On the other hand, all theme-related utils, like |
It seems that it is halfway done. So if @material-ui/styles will go, I suggest we add a
|
We won’t support this API in v5 (at least not as utils from core using emotion), we plan to support the |
We could add it, for compatibility reason, and maybe mark it as deprecated in the first minor or something. |
If I'm understanding this correctly the DataGrid component is an expectation to the case where a component needs to be v4 and v5 compatible at the same time, right? Also, I remember when we were adding the v5 support it was always meant to be temporary and once v5 is released we would migrate the DataGrid fully as well. If that is the case then we can have it as it is proposed for now and remove the |
I should check whether and how this will be possible, I am not sure if it is trivial change. Even if we add it I would mark it as deprecated, as I don’t think the core should in the long run support this. cc @oliviertassinari @eps1lon for opinion or ideas |
I didn’t know this, I thought the |
Looking at the thread it seems that we need to precise the direction. It seems that there is confusion around this point: the intent is to progressively remove makeStyles and withStyles. The changes pushed here are meant to meet halfway between the need to drop
Do we want to commit to it? Regarding making it easy for third-party libraries to transition from v4 to v5, or even supporting them both for a couple of months. It seems that we have 3 options:
|
it seems like an option 🤔 .
Another option would be to add the
|
I will look into adding |
@oliviertassinari seems like this is not possible because of the JSS singleton? Or am I missing something? |
From the first look, supporting I did some exploration today - https://codesandbox.io/s/makestyles-with-emotion-zfeyx?file=/src/App.tsx (the solution is inspired by emotion-js/emotion#1853 (comment), only the API is adjusted to our use-cases). The first problem I have is that I cannot override styles defined by the Taking into account that this is only needed for like very short period of time (transition), I am not sure how smart it is to invest too much time into making it all work when anyway don't plan to support it in the long run. So maybe we should look more Option 1 - rely on
|
@mnajdova I believe that it's option 1, what you have initially pushed in this PR. For the data grid, it seems good enough, Thanks for exploring option 3. For my perspective, the biggest value of makeStyles powered by emotion would be for members of the community. Did we consider option 2? |
Haven’t tried it yet. Looks like it could be easier then to migrate to the current I didn’t go in this direction, as when we will get to |
@dtassone @DanailH would be great if I can get a review, I need to resolve merge conflicts each time there is a commit on master. Would suggest reviewing with hidden white spaces changes - https://github.com/mui-org/material-ui-x/pull/1627/files?diff=split&w=1 |
It works with core v5 👍 https://codesandbox.io/s/material-demo-forked-jl74j?file=/demo.js |
Resolving last conflicts and merging. Thanks everyone on the input :) |
Changes done in the PR:
theme
inmakeStyles
I just changed the import from@material-ui/core/styles
to@material-ui/styles
.theme
usage, I've added thedefaultTheme
arg in themakeStyles
options to be the result ofcreateMuiTheme()
. If there is another theme in the context, it will be picked up anyway by themakeStyles()
util.