raster-foundry / blasterjs

React UI library designed and built by Azavea
https://raster-foundry-blaster.netlify.com
Other
6 stars 3 forks source link

Nested Text components don't inherit styles as expected #234

Closed alkamin closed 4 years ago

alkamin commented 5 years ago

It's possible that this is just a bad assumption, but doing the following resulted in unexpected results:

<Text fontSize={4}>
   <Text fontWeight="bold">Hello</Text>World
</Text>

image

I expected the inner Text component to also have a fontSize of 4.

designmatty commented 5 years ago

I think that's a safe assumption. If I were to write the html <p>...<span>...</span></p> I would expect the span to be the same size as the p unless I manually changed it.

This would be a pretty straightforward fix, by setting a default prop for fontSize = inherit. We should ensure this doesn't have any unintended issues though.

I manually tested this fix by setting fontSize to inherit in this example and it works well, so I assume a default prop will work just as well: image

I also checked to see if any other props would need this treatment, but it doesn't seem to be the case.