You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 and isDark functions from 'tinycolor2' to make it easy to determine the lightness of a color.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
isLightandisDarkfunctions from 'tinycolor2' to make it easy to determine the lightness of a color.