datchley / react-scale-text

A React library to keep an element's text scaled to fit it's container
MIT License
54 stars 18 forks source link

Allow non-Element children #2

Closed datchley closed 7 years ago

datchley commented 7 years ago

Currently, ScaleText only allows Elements as the prop type for children; and it only applies to the first element in it's list of children. This isn't completely intuitive.

It'd be nice to allow renderable children, ie string, number, node, etc., and ensure that, in development mode, it warns you when there is more than one top level child. For non-node/element children, it would wrap them in a <span> before rendering.

Basically, ensure we allow for the following primary use cases:

<ScaleText>Hello World!</ScaleText>
<ScaleText>{2017}</ScaleText>
datchley commented 7 years ago

Works with latest version, simply wraps non-valid ReactElements in a <span/> to allow setting the font-size.