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

Add prop for easy centering #73

Closed
cupcakearmy opened this issue Jan 23, 2019 · 2 comments
Closed

Add prop for easy centering #73

cupcakearmy opened this issue Jan 23, 2019 · 2 comments

Comments

@cupcakearmy
Copy link

There should be an option for fast, easy centring of children.

// From
<FlexView vAlignContent={'Center'} hAlignContent={'center'} />

// To
<FlexView center />

Alternatively one could have the vAlignContent fields default to center

//From
<FlexView vAlignContent={'Center'} hAlignContent={'center'} />

// To
<FlexView vAlignContent hAlignContent />

Any thought?

@FrancescoCioria
Copy link
Contributor

Hi @cupcakearmy

I don't like that idea much...
We get to write a few characters less at the expense of readability (second option) and complexity of props API (both options).

Personally, I prefer basic components to be as simple as possible: with React you can very easily wrap them and customize the API as you wish.

That is exactly what I'd suggest you to do:

/* FlexView.js */

import FlexView from 'react-flexview';

export default ({ vAlignContent, hAlignContent, ...props }) => (
  <FlexView
    vAlignContent={vAlignContent === true ? 'center' : vAlignContent}
    hAlignContent={hAlignContent === true ? 'center' : hAlignContent}
  />
)

@cupcakearmy
Copy link
Author

That is a good suggestion. I'll close the issue. Thanks for the quick feedback 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants