whocanuse
whocanuse copied to clipboard
Add SAPC support
https://github.com/Myndex/SAPC/tree/master/JS
I expect to have an npm package soon. Also just as an FYI we're calling the basic free algorithm "APCA" now... SAPC is the full appearance model...
APCA npm Package
The APCA npm package is now available: apca-w3
Install:
npm i apca-w3
Usage:
And the API is trivially simple: send it two colors, it returns a signed INT of the Lc value (lightness contrast).
Lc = APCAcontrast( sRGBtoY( textColor ), sRGBtoY( backgroundColor ) );
Implementation notes:
Color sent to the required parsing function sRGBtoY()
can be a 3 or 6 character hex string #fff
or a3b3d4
(hash # is optional but not required), a named CSS color (such as aquamarine
), as rgb(99,122,14)
, or as a number 0x123456
or 15213412
. Text color first, background color second — do not swap colors, as use case affects results. light text on a dark background returns a negative value.
For questions and comments please visit the main APCA repo discussion area.
Thank you!
Andy
Hey @CoreyGinnivan I'm not sure if you are aware but we released Bridge-PCA which is backwards compatible with the old WCAG 2, but using APCA technology — if you pass Bridge-PCA you automatically pass WCAG 2.
Also available as an npm package:
npm i bridge-pca
Thank you!
Andy