jonnykates
4/22/2018 - 4:27 PM

contrast-checker.scss

@function colour-difference($foreground, $background) {
  $r: (max(red($foreground), red($background))) - (min(red($foreground), red($background)));
  $g: (max(green($foreground), green($background))) - (min(green($foreground), green($background)));
  $b: (max(blue($foreground), blue($background))) - (min(blue($foreground), blue($background)));
  $sum-rgb: $r + $g + $b;
  
  @if $sum-rgb < 500 {
    @return "false";
  } @else {
    @return "true";
  }
}