-
-
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
[docs] Replace makeStyles/withStyles with sx prop and styled #16947
Comments
@oliviertassinari what is the exactly the tasks in hand? Here is what I understand,
Is this correct? |
@yordis I think that the timing is going to be key in this transition. I would imagine the following steps:
|
@oliviertassinari I'm curious, and I apologize if this was repeated: why not keep |
@ConAntonakos it's an option. It could help if we need to extend/normalize some of the features of styled-components. |
@oliviertassinari do we have a list of what's left? |
@yordis We haven't done many efforts in this direction yet. However, there is a probability that it will require breaking changes, v5 is planned for around Q4 2020. I think that we should explore a partial deployment strategy for developers that want to leverage it sooner. Now, this effort has to be balanced with the other priorities, like the support of new advanced components (free and paid) or the release of an unstyled version of the library to increase our audience reach (with different themes, e.g. iOS style). The good news is that we will likely grow the team in the coming months, enabling us to move faster. I imagine you are already using styled-components on top of Material-UI today as many other developers do (and not From a product perspective, our incentive is about: smaller bundle size, better performance, steaming support, fewer bugs, CSS template strings support, larger community, enables to use the system props in the core components, allow true dynamic themes and props support, better docs. |
Yeah, I tried to change some examples, but they require some integration with the theme provider, so we may need to inject
That is far enough, would it be better to pin different issues for visibility on what is a priority at the moment?
Actually, I am quite happy with
I am trying to help with the migration, personally, no pain points. Unless you take into consideration that as an ecosystem, I have to maintain two ways to develop something, but meh, personally, it is okay for me. Maybe Let me know how I could help, like I said, I was using the pinned issues to find the prioritization of the Org |
It depends on the time horizon you are interested in. You can follow the issue with the label I don't fully understand this point. Why not using styled-components when using Material-UI (today)? We had 1/3 of our users going down this path when we did our last survey, 6 months ago. |
Thank you for the info about prioritization. |
@yordis btw, my answer was made under the assumption you were following up on the main styled-components issue. I haven't realized we were on the documentation one. |
@oliviertassinari do you have any suggestions about the issue with theme context? I tried to use |
Hey @oliviertassinari! Are you looking for PR's that convert the existing customization demos to use styled-components as part of this issue? |
I dont think |
And get almost fully typed. Don't see any reason to migrate +1 |
@thclark, @cjnoname Is the dislike about the styled() API the CSS template string syntax (JavaScript object works too)? Or the love about makeStyles in its capability to have multiple class names ( We have talked about bringing |
To me, the best thing about makeStyles is the capability to have muliple class names declared side by side. That allows us to have all the styling used in a component/file declared in a single place and resuse a lot of the styling. In my opinion it does also make much more sense to apply separate styling from the jsx. I think the new demos with the new As a reference, this is an example of makeStyles-usage in a lot my projects: import classnames from 'classnames';
import { makeStyles } from '@material-ui/styles';
const useStyles = makeStyles((theme) => ({
grid: {
display: 'grid',
gridGap: theme.spacing(2),
gridTemplateColumns: '1fr 1fr',
[theme.breakpoints.down('md')]: {
gridTemplateColumns: '1fr',
gridGap: theme.spacing(1),
},
},
column: {
gridTemplateColumns: '1fr',
},
margin: {
margin: theme.spacing(1),
},
}));
const Example = () => {
const classes = useStyles();
return (
<div className={classnames(classes.grid, classes.margin)}>
<div className={classnames(classes.grid, classes.column)}>{/* ... */}</div>
<div className={classnames(classes.grid, classes.column)}>{/* ... */}</div>
</div>
);
}; |
can totally ask in a separate thread, but realized that the default emotion api is the styled api. will it support using the css api as well? |
Thanks for asking. I don't care what's behind "makeStyles". It doesn't matter if it's JSS or Emotion, but "makeStyles" is just a great syntactic sugar I'd like to use. I am pretty sure that a lot of MUI users are moved from Style Component in order to be avoid of working with 'styles()' syntax. |
We really like I agree as well, styled components are quick messy in a lot of cases. I'm not opposed to using them when I'm trying to wrap and re-export a single component, but when I'm just trying to apply a few additional styles to my JSX I vastly prefer the makeStyles hook syntax. |
@oliviertassinari my main dislike is the template string syntax. I know that Perhaps, in that light, if the mui docs adopted a convention of using JSS in all the styled examples, that would be one way of easing the transition from makestyles. |
one thing I miss ATM is being able to run stylelint on the makeStyles code. i'm assuming using regular css syntax will allow us to do that with this new approach? it seems like emotion has stylelint support already? |
@kelly-tock I do this to get linting on standard CSS (also IIRC soon import { css } from "@emotion/react";
import { Box, experimentalStyled as styled } from "@material-ui/core";
const MyBox = styled(Box)(
({ theme }) => css`
display: flex;
margin-top: ${theme.spacing(2)};
padding: ${theme.spacing(2)};
`
); |
I have created #26571 to have a place for the community to contribute to the pain generated by putting |
Following #6115, I think that we should migrate all our demos to use the Box component or styled-component. The goal is to hide
@material-ui/styles
as much as possible. styled-components keeps growing, a consolidation of this styling solution will be better, overall, for the React community.Regarding the timing, I think that we can start to use the Box component now. For the demos that we can't migrate, we probably want to wait for the first proof of concept with #6115.
Attached is a list of component demos that should be migrated to the new style API.
Docs infra
Misc
/docs/src/pages/getting-started/templates/
[docs] Migrate templates to emotion #26604/test/regressions/
, e.g. TestViewer.js [test] Migrate regressions to emotion #27010/docs/src/pages/premium-themes/
[docs] Migrate paperbase premium template to emotion #26658 [docs] Migrate onepirate premium template to emotion part1 #26671 [docs] Migrate onepirate premium template to emotion part2 #26707Layout
Inputs
Navigation
Surfaces
Feedback
Data Display
Utils
Lab
The text was updated successfully, but these errors were encountered: