Sass functions that support accessible color contrast ratios
Minimum Sass version 3.4.25. Libsass 3.5.4 (best performance).
Editable sandbox on CodePen to see how this all works. Change the color variables to see the updates in real-time within the size tests.
When an edge case has been encountered, a version in SassMeister with debug output is helpful to see what might be happening (I changed the main function to a mixin so I can debug the output):
sassmeister.com/gist/42b8402a3cb5ac41f8557df4e175b1f7
Programming Sass to Create Accessible Color Combinations
pow()
function but it was not performant. Then I used a lookup table and that worked pretty well. Better still, Merovex provided a succinct and performant pow()
from Hail2u@while
Sass statement help from Merovex