Skip to content
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

feat(spacings): support justify-content prop for Inline/Stack components #557

Merged
merged 4 commits into from
Feb 19, 2019

Conversation

emmenko
Copy link
Member

@emmenko emmenko commented Feb 19, 2019

Fixes #552

Additional change

I also deprecated the alignItems values written in camelCase, which I found weird as we should simply pass the normal css values. So the "old" values are still supported for backwards compatibility.

Copy link
Contributor

@qmateub qmateub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me! Looking forward to have this in 🎉

Should we add also the justifyContent to the story of Stack and Inline? 🤔

@emmenko
Copy link
Member Author

emmenko commented Feb 19, 2019

Should we add also the justifyContent to the story of Stack and Inline? 🤔

I won't affect the story, because of how it's being setup. We could add more examples in the story but then we're just testing how flexbox works, so I opted to just keep it as is.

Copy link
Contributor

@montezume montezume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a VRT for this?

@emmenko
Copy link
Member Author

emmenko commented Feb 19, 2019

What do you suggest to test in the VRT?

@emmenko
Copy link
Member Author

emmenko commented Feb 19, 2019

Or do you mean VRT for spacing components in general?

@montezume
Copy link
Contributor

Or do you mean VRT for spacing components in general?

@emmenko just make a test using this prop? Add it to the spacings vrt test in the stack and inline sections? 🙏

Sent with GitHawk

'flex-end',
'center',
// Deprecated
'flexStart',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we warning when they're used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that might end up with a lot of noise. We can maybe do that in the next major, then in the major after that we can remove them completely.
So a two-step deprecation process.

@emmenko
Copy link
Member Author

emmenko commented Feb 19, 2019

@emmenko just make a test using this prop? Add it to the spacings vrt test in the stack and inline sections? 🙏

Sure, I'll see what I can do

@emmenko
Copy link
Member Author

emmenko commented Feb 19, 2019

Alright, I added some VRT for the justifyContent prop. I also removed the prop from the Stack component, as I realised that it's pretty much useless for flex columns (at least I couldn't find a use case for that).

].map(prop => (
<Spec
key={`inline-justify-${prop}`}
label={`Inset - when justifyContent is ${prop}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the VRT for inset not inline though 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry just a typo

@emmenko emmenko force-pushed the nm-spacings-justify-content branch from dc84ded to ce7ed9a Compare February 19, 2019 15:05
@emmenko emmenko merged commit 5bd61e7 into master Feb 19, 2019
@emmenko emmenko deleted the nm-spacings-justify-content branch February 19, 2019 15:24
@ahmehri
Copy link
Member

ahmehri commented Apr 8, 2021

@emmenko I was going to request supporting justify-content for the component Spacings.Stack. I first searched the repository which led me to this PR. The title insinuates that it's already supported, but when I checked the changes it's not. Any reason why the support wasn't added to the component Spacings.Stack as well?

@emmenko
Copy link
Member Author

emmenko commented Apr 9, 2021

@ahmehri in general, for vertical items (spacing stack) justify-content only works if the container has a fixed height. This is usually not the case for a spacing stack component, as the height is not defined and determined by the number of items and their dimension.

Can you describe your use case?

@ahmehri
Copy link
Member

ahmehri commented Apr 9, 2021

Yes, my use case is positioning two items vertically with a container that has a fixed height, and position them in a way that there is a space between them.

CleanShot 2021-04-09 at 15 35 55@2x

I achieved that using the component Grid, but Flexbox layout (the Spacings.Stack component) is more suitable here because of having only one dimension. The same can be achieved using Spacings.Stack if justify-content was supported (of course the container still needs to have a fixed height).

CleanShot 2021-04-09 at 15 38 44@2x

<Spacings.Stack style={{ height: "100%" }} alignContent="space-between">
  <ImageLabel />
  <Controls />
</Spacings.Stack>

@emmenko
Copy link
Member Author

emmenko commented Apr 9, 2021

I see. Given that this is a special case anyway (fixed height, etc), I would suggest maybe to use a <div> with custom styles, as you only want a flex container and the spacing is not an important factor.

Does that make sense?

@ahmehri
Copy link
Member

ahmehri commented Apr 9, 2021

In a way, but the idea is to use the ui-kit component in favor of the custom styles (the ultimate goal is to get rid of all the custom styles). Given that the component Spacings.Stack works in both cases (whether the container has a fixed height), I don't see why we should not support the property justify-content. The idea of using the component is to be able to use the Flexbox layout using a React component instead of writing a custom CSS. Not supporting the property justify-content is a limitation in my opinion.

Another argument is to achieve symmetry between components Spacings.Inline (flex-direction: row) and Spacings.Stack (flex-direction: column). The former supports both properties justify-content and align-items whereas the latter supports only one.

@emmenko
Copy link
Member Author

emmenko commented Apr 9, 2021

One thing to keep in mind is that the spacing components are not the same as flex box containers. Yes, they use flex but they aim to solve a specific use case.

I don't have a problem with adding the justifyContent prop, that's not the point.

Even if we add that, you still need to solve the problem with the fixed height to solve your use case, right?
So does that mean we need to also add a height prop?

Or how did you plan to solve that issue?

PS: we can also think if it makes sense to add a <Flex> component, similarly to <Grid>.

@ahmehri
Copy link
Member

ahmehri commented Apr 12, 2021

You're right, passing prop style (style={{ height: "100%" }} to set the fixed height) to the component Spacings.Stack won't have any effect. This is not the case for the component Grid, in fact, that's how I was able to set the fixed height for the grid container.

One thing to keep in mind is that the spacing components are not the same as flex box containers. Yes, they use flex but they aim to solve a specific use case.

I'm more convinced now about this and think adding a new component Flex as Grid is the best solution.

@emmenko
Copy link
Member Author

emmenko commented Apr 12, 2021

Sounds good then, PR welcomed. PS: it can also be an onboarding task if you want 😉

First thing maybe to open an issue describing the use case. Thanks 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💅 Type: Enhancement Improves existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants