typestyle / csx

Utility functions for TypeStyle
https://typestyle.github.io
MIT License
102 stars 14 forks source link

ColorHelper can produce invalid colours #18

Closed jamiewinder closed 7 years ago

jamiewinder commented 7 years ago

[Demo](http://typestyle.io/play/#src=const%20myStyle%20=%20style(%7B%0A%20%20background:%20csx.color('#16A085').darken('10%25').toHexString()%0A%7D);%0A%0Aconsole.log(csx.color('#16A085').darken('10%25').toHexString());%0A%0A%3Cdiv%20className=%7BmyStyle%7D%3E%0A%20%20This%20is%20a%20test%0A%3C/div%3E)

The <div> should be dark green, but isn't. The reason seems to be that .darken('10%').toHexString()' has produced an invalid hex:#0107360` (note it is seven digits long)

notoriousb1t commented 7 years ago

This is fixed in 8.0.6. There was a rounding error: https://github.com/typestyle/csx/commit/719a3590007fda9523b6f2fe84d35207d70af4e8