-
-
Save WMTAndroidJaymin/8457b3e5b835a61f8f5c9d67aea5051f to your computer and use it in GitHub Desktop.
SASS - Loop through array to create class sets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Set Variables | |
$button-white: #ffffff; | |
$button-green: #44ca00; | |
$button-green-dark: #369a12; | |
$button-blue: #a6d1f9; | |
$button-blue-dark: #14283e; | |
$button-gray: #eeeeee; | |
$button-red: #9e0b0f; | |
//Create Array | |
$button-colors: (green $button-green white, | |
darkgreen $button-green-dark white, | |
blue $button-blue white, | |
darkblue $button-blue-dark white, | |
gray $button-gray #999, | |
red $button-red white | |
); | |
//Each loop to create classes | |
.button { | |
@each $type in $button-colors { | |
&.#{nth($type, 1)} { | |
background-color: #{nth($type, 2)}; | |
color: #{nth($type, 3)}; | |
&:hover { | |
background-color: darken(nth($type, 2), 5%); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment