-
-
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
[Layout] align
and justify
have no affect on item
#6013
Comments
Good question. I'm assuming
That combination hasn't been taken into account when designing the component.
We could be using the following helper to make that clear. But we need to update the propType generator to understand it. const requireProp = requiredProp => validator =>
(props, propName, componentName, location, propFullName, ...args) => {
const componentNameSafe = componentName || '<<anonymous>>';
const propFullNameSafe = propFullName || propName;
if (typeof props[propName] !== 'undefined') {
warning(
props[requiredProp],
`The property \`${propFullNameSafe}\` of `
+ `\`${componentNameSafe}\` must be used on \`${requiredProp}\`.`
);
}
return validator(props, propName, componentName, location, propFullName, ...args);
};
// ...
align: requireProp('container')(PropTypes.oneOf([
'flex-start',
'center',
'flex-end',
'stretch',
])), Regarding your specific example, I would rather be doing the following. <Layout container>
<Layout item xs={2} />
<Layout
item
container
xs={4}
align="center"
justify="center"
>
<Layout item>
foo
</Layout>
</Layout>
<Layout
item
container
xs={4}
align="center"
justify="center"
>
<Layout item>
bar
</Layout>
</Layout>
<Layout item xs={2} />
</Layout> |
I was expecting it to yield I think there will be great confusion about the usage of
|
I'm going to try your example. I'm coming around to the understanding that something could be both |
Yes, it can. We fully embrace the flexbox model. That ambivalence is at the heart of the model. A flex container can also be an item.
I agree 💯 . I will do it. |
@oliviertassinari Is there any documentation on how to use |
@annjawn The component was renamed |
Description
While you are allowed to specify
align
andjustify
on a<Layout item/>
, these props have no effect because the component is missingdisplay: flex
. If these are valid props, we need to adddisplay: flex
. If these are not a valid combination, we may need to consider either a warning or splitting components to prevent misuse.Implementation note
I haven't seen this in the
next
code yet, but I'm using the technique in my own app. This might be an easy way to make sure the prop gets added by doing:Link to minimally-working code that reproduces the issue
Versions
next
The text was updated successfully, but these errors were encountered: