Skip to content

Add WCAG contrast level checker#28

Merged
acheronfail merged 6 commits intoacheronfail:masterfrom
fabianlindfors:master
Dec 17, 2020
Merged

Add WCAG contrast level checker#28
acheronfail merged 6 commits intoacheronfail:masterfrom
fabianlindfors:master

Conversation

@fabianlindfors
Copy link
Copy Markdown
Contributor

This PR adds a new feature allowing users to check the WCAG contrast level (https://www.w3.org/TR/WCAG20/) between two picked colours. When picking a colour, a new label will appear indicating the contrast level compared against the previously picked colour. The background of the label will also match the previous colour, providing for a nice side-by-side visualization.

There are four possible levels: AAA, AA, OK, and Fail. WCAG doesn't define a contrast ratio for level A and hence I opted to call it OK instead.

Here's what the feature looks like in action, comparing the heading colour to the background:

wcag_example

The feature is disabled by default and can be enabled with a toggle in the menu.

Remaining work

I have yet to add any information to the README as I thought I would check in with you first. Would you like the feature to be mentioned in the README? If so, what emoji would you find fitting? I personally like 🌓!

Based on code from https://gist.github.com/ngquerol/23d6d5ebd051e18682badafa37e48442. The calculated contrast ratio can be passed to the WCAGLevel constructor to get the final contrast level.
When enabled, a new label will show up in the picker detail view. The label will show the WCAG contrast level between the currently color and the previously picked one. The background color of the label is also the previously picked color to provide a visualization of the contrast.
@acheronfail
Copy link
Copy Markdown
Owner

Looks great!

I have yet to add any information to the README as I thought I would check in with you first. Would you like the feature to be mentioned in the README? If so, what emoji would you find fitting? I personally like 🌓!

I'm happy with that - seems like a good fit to me. Throw that in and we can get this through. :)

@karbassi
Copy link
Copy Markdown

@fabianlindfors Do you need any help so we can merge this?

@viktorstrate
Copy link
Copy Markdown
Contributor

I would love to see this feature merged

@fabianlindfors
Copy link
Copy Markdown
Contributor Author

This totally slipped my mind, sorry about that! @acheronfail @karbassi @viktorstrate

The README has been updated now and if everything looks good then it's ready to merge!

@acheronfail acheronfail merged commit 71f49f4 into acheronfail:master Dec 17, 2020
@acheronfail
Copy link
Copy Markdown
Owner

Thanks for the PR!
I should be able to create a release sometime in the next few weeks (don't have a mac right now).

On that note I think github actions have apple machines now, so I could look into that too...

@karbassi
Copy link
Copy Markdown

karbassi commented Dec 17, 2020

@acheronfail you can have GitHub actions create the release if you'd like. Here is an example of a project I lead.

https://github.com/michaelvillar/timer-app/blob/master/.github/workflows/release.yml

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.

4 participants