Skip to content

Instantly share code, notes, and snippets.

@emilushi
Created May 8, 2019 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilushi/488743cb4cfc0e17ae8da9b208922af1 to your computer and use it in GitHub Desktop.
Save emilushi/488743cb4cfc0e17ae8da9b208922af1 to your computer and use it in GitHub Desktop.
SASS Loop to set properties based on predefined list.
$schema1: white $white $white;
$schema2: core-brand-color $color__brand-green $color__brand-green;
$schema3: secondary-brand-color $color__brand-blue $color__brand-blue;
$schema4: black $black $black;
$schema5: coral coral coral;
$schema6: darkblue darkblue darkblue;
$schema7: darkgrey darkgrey darkgrey;
$schema8: lightblue $color__brand-lightblue $color__brand-lightblue;
$schema9: purple purple purple;
$schema10: red $color__brand-red $color__brand-red;
$schema11: tan tan tan;
$schema12: yellow yellow yellow;
$schemes: $schema1 $schema2 $schema3 $schema4 $schema5 $schema6 $schema7 $schema8 $schema9 $schema10 $schema11 $schema12;
@each $schema in $schemes {
.#{nth($schema, 1)}-button {
background-color: nth($schema, 2);
border-color: nth($schema, 3);
@if nth($schema, 1) == white OR nth($schema, 1) == yellow OR nth($schema, 1) == tan OR nth($schema, 1) == darkgrey {
color: $color__brand-blue;
} @else if nth($schema, 1) == black OR nth($schema, 1) == darkblue OR nth($schema, 1) == red OR nth($schema, 1) == purple {
color: $white;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment