question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

💡 Proposal - Flex component for F36

See original GitHub issue

👋 F36 community!

I would like to propose to create Flex component for F36. I think there might be cases where we add additional styles just to add flex and position elements with it, or maybe to add flex and specify spacing between elements. It might be useful to have a generic component in the library that could do it for us, like <Flex />. I know that we have <Grid /> already, but I guess there is still room for <Flex /> to handle less complex cases. Flex is still very much in use and it’s good to have a choice between those 2 components in the library, in my opinion.

Flex component potentially could take following props:

Prop Description
fullWidth boolean, sets width to 100%
fullHeight boolean, sets height to 100%
noShrink boolean, sets flex-shrink to 0 - default is 1
alignItems string, one of align-items css values
alignContent string, one of align-content css values - maybe this one is actually not needed?
justifyItems string, one of justify-items css values - maybe this one is actually not needed?
justifyContent string, one of justify-content css values
alignSelf string, one of align-self css values
direction string, one of flex-direction css values
wrap boolean, sets css value of flex-wrap to wrap
wrapReverse boolean, sets css value of flex-wrap to wrap-reverse

We could also have options for margins suited for using spacing tokens only:

Prop Description
margin string, accepts one of the spacing tokens and pass it to margin="spacingL" to margin: 1.5rem
marginTop string, accepts one of the spacing tokens like marginTop="spacingL" transformed to margin-top: 1.5rem
marginBottom string, accepts one of the spacing tokens like marginBottom="spacingL" transformed to margin-bottom: 1.5rem
marginLeft string, accepts one of the spacing tokens like marginLeft="spacingL" transformed to margin-left: 1.5rem
marginRight string, accepts one of the spacing tokens ike marginRight="spacingL" transformed to margin-right: 1.5rem

The proposed solution

At the end this component would end up as something like this:

<Flex
  direction="column"
  alignItems="center"
  justifyContent="center"
>
  <Flex marginRight="spacingL">I have 24px margin on the right side</Flex>
  <OtherComponent />
</Flex>

I’m curious WDYT, thx for any comments or feedback 🙂

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mshaaban0commented, May 23, 2020

@burakukula Thank you for your proposal.

IMO, I was hoping to see us using standard CSS more often, however, since emotion is already draining our web-app performance, and flex is used more than 400 times in our code base

@wichniowski pointed out that this component could actually help us to reduce the cpu usage caused by styles recalculation, which I believe is a great point, and it would be nice to validate that

I would be interested to see if this component can actually help us if we rely on css only when we build it.

Screenshot 2020-05-18 at 13 32 48 Screenshot 2020-05-19 at 21 02 44
1reaction
mshaaban0commented, May 25, 2020

@burakukula yes, we can create two react components one with emotion and one with css only, render each 1000 times in an empty html, and use react profiler to see the results. feel free to reach out if you want to pair on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flex - Forma 36
The Flex component is useful because it helps with several common cases: create a one direction layout (vertical or horizontal) with uses Forma...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found