styled-components / polished

A lightweight toolset for writing styles in JavaScript ✨
https://polished.js.org/
MIT License
7.64k stars 209 forks source link

Lighten seems to go from 0 - 0.2 is the maths broken ? #580

Closed leojauncey closed 3 years ago

leojauncey commented 3 years ago

What You Are Seeing

lighten seems to return white for any value over 0.2

What You Expected To See

lighten amount from 0 to 1

aleksandrlat commented 3 years ago

@leojauncey it depends on current color lightness.

Color is converted to HSL format in lighten function https://github.com/styled-components/polished/blob/main/src/color/lighten.js#L32

When color is converted to HSL it already has some lightness.

Please refer to https://en.wikipedia.org/wiki/HSL_and_HSV

Maybe just setLightness instead