malte-wessel / react-textfit

React component to fit headlines and paragraphs into elements
http://malte-wessel.github.io/react-textfit/
MIT License
474 stars 144 forks source link

Add 'array' as an accepted PropType #23

Closed ValBerthe closed 7 years ago

ValBerthe commented 7 years ago

It would be useful to have JSX arrays accepted as Textfit child.

For example:

[ <strong>Hello</strong>, <em> world</em>, "!", <br/> ]

It is actually working but it throws the error:

Warning: Failed prop type: Invalid prop 'children' supplied to 'Textfit'.

denis-sokolov commented 7 years ago

Thank you for your contribution! This feature makes sense to me. The following is how it would be used:

<Textfit>
  <strong>Hello</strong> <em>world</em>! <br />
</Textfit>

Before we can merge it, we need to ensure we do not break it in the future. We do not have automated tests set up, but we do have the example/demo. So to merge this PR, we need to add this use to the example. For instance, one of the Lorem Ipsum paragraphs can have strong and em elements as in your example. This way, if we break the feature, we will see it on our example page quickly.

We also need to use this new feature in the documentation. No need to bring a lot of attention to it, but if one example includes structure like this, the users will see that it is an acceptable usage.

You don’t have to do these improvements yourself, @ValBerthe, but if you do them, I will be able to merge this feature in sooner. Otherwise, I or someone else will do this eventually.

ValBerthe commented 7 years ago

@denis-sokolov Nice, thanks for your answer ! I added some strongs and ems and brs in the third long paragraph of the demo. Hope it's going to be visible enough.

I'll update the docs asap 👍

denis-sokolov commented 7 years ago

@ValBerthe, thanks for addressing my comments! I am traveling right now, thus the worst case scenario I merge this in in two weeks. Don’t feel forgotten if that happens, it’s on my list. Though I hope to do this during the trip.

denis-sokolov commented 7 years ago

Thank you!