Skip to content

Port newer color readability functions from TinyColor#6681

Open
DavidHarvey wants to merge 2 commits intoGrapesJS:devfrom
DavidHarvey:tinycolor-readability
Open

Port newer color readability functions from TinyColor#6681
DavidHarvey wants to merge 2 commits intoGrapesJS:devfrom
DavidHarvey:tinycolor-readability

Conversation

@DavidHarvey
Copy link
Contributor

The "port" of TinyColor is either old, or modified, such that readability methods return unexpected results. This simply ports the latest readability methods (and necessary complementary methods, like getLuminance).

As an example, take the background color #0066cc and the foreground color #fff. This combination passes all WCAG contrast checks, except for AAA on normal sized text (See: https://webaim.org/resources/contrastchecker/?fcolor=FFFFFF&bcolor=0066CC)

Before:

-> tinycolor.isReadable('#0066cc', '#fff')
<- false

After:

-> tinycolor.isReadable('#0066cc', '#fff')
<- true

-> tinycolor.isReadable('#0066cc', '#fff', {level: 'AAA', size: 'small'})
<- false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant