mardi 16 mars 2021

SASS Loop Background Colors, Change Text Color

My current project has me looping through an array of colors and applying them to boxes. So far that works - however, for the colors that are too dark, i need to change the text color to white. How can I make that happen?

$chartColors: $color__blue, $color__yellow, $color__grey,
  $color__orange, $color__gold, $color__light-blue, $color__turq,
  $color__pacific-grey, $color__green;
    
$chartColorsLength: length($chartColors);
    
.post-box,
.category-box {
  @for $i from 1 through $chartColorsLength {
    &:nth-of-type(#{$chartColorsLength}n + #{$i}) {
      background-color: nth($chartColors, $i);
      /* below doesn't work */
      @if background-color == $color__blue or background-color == $color__grey {
        p,
        a,
        h4 {
          color: #fff;
        }
      }
    }
  }
}

Aucun commentaire:

Enregistrer un commentaire