Open hpohlmeyer opened 5 years ago
I think you can use tinycolor2
directly.
Yes, that’s what I was doing intially, but it could bring maintainance overhead.
I don’t really care for the tinycolor2
version that is used to determine the lightness of the color, but since I would need to use tinycolor2
directly, there are a few ways to approach this:
Use tinycolor2
without having it in the package.json since I know it is there and typescript will notify me if @ant-design/color
does not use it anymore.
npm install
the latest version of tinycolor2. If @ant-design/color
does not use the latest version that would leave me with two versions of tinycolor2
.
npm install
a specific version of tinycolor2
and manually keep it in sync with the @ant-design/color
version, which has to be noted somewhere and could easily be forgotten if someone else is updating the project dependencies.
Having the functions exposed by the @ant-design/color
package would just let me use the provided functions without having to manually deal with an additional package.
I was thinking that determining the lightness of a color is a very common practice and thus would be a nice addition to this package.
It is very common to overlay generated colors with text, as you do in the demo screenshot. It would be nice to determine if a generated color is light or dark to decide what color should be used for the overlaying text.
This PR exposes the
isLight
andisDark
functions from 'tinycolor2' to make it easy to determine the lightness of a color.