-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Grid] API sugar proposal #10343
Comments
@rogovdm This issue is deeply linked to #6140. I was suggesting doing it the other way around: <Grid
xs={12}
xsGrow={1}
xsDirection={column}
lg={6}
hidden={{ xlUp: true }}
> or <Grid
xs={{
size: 12,
grow: 1,
direction: column,
}}
lg={6}
hidden={{ xlUp: true }}
> But I'm not sold on any specific API. It's something we can start thinking about for Material-UI v2. |
@oliviertassinari I would target for an API that it is flexible to changes. If you go for The second approach at least it is clear what is it doing, for From code perspective, you dont need to pay that much attention on the breakpoints as long as you had configured the values somewhere (either by configuration the theme or a single object on the code). |
Thinking on enhancement API for Material-UI v1 that's not break anything... <Grid
container
xsDirection="column"
mdDirection="row"
xsAlignItems="center"
mdAlignItems="baseline"
{...othersProps}
>
/* code here*/
</Grid> them, to not be a Today, I can accomplish this using withWidth, them my code became this: (no judge here, pls xD) <Grid
container
direction={width === "xs" ? "column" : "row"}
alignItems={width === "xs" ? "center" : "baseline"}
{...othersProps}
>
/* code here*/
</Grid> |
After reasoning about this I think the best approach is to minimize the amount of CSS we need for this and by so the bundle size decrease and maybe is not that bad to use style attributes or classes by without the breakpoint scoping since it wouldn't matter. Something really similar to what @itelo shared. With a declarative component and some helper function that makes it easier and friendly to read we could use <MatchBreakpoint>
(breakpoint)=> {
<Grid
container
direction={breakpoint === "xs" ? "column" : "row"}
alignItems={breakpoint === "xs" ? "center" : "baseline"}
{...othersProps}
></Grid>
}
</MatchBreakpoint> The more I think about this the more I like this approach, the only concern it would be the performance of @oliviertassinari In any case, I would love to push Would you take a PR for the component? |
Btw, it is kind of like
|
I'm closing for #6140 |
Grid component has quite a few props. And those are great. A person (or a group) who came out with this API are awesome 👍
I have a small proposal. In order to group properties visually (because it'a lot of them) I came up with this idea:
Nice, but why not proposing adding a
sizes
prop?To be clear. The benefit is to have them grouped. When it's time to do some adaptive stuff there is a lot going on with those values.
The text was updated successfully, but these errors were encountered: