Skip to content

Instantly share code, notes, and snippets.

@celsowhite
Last active January 16, 2017 17:58
Show Gist options
  • Save celsowhite/7e3022b5eb528a03aa87220b2de67d63 to your computer and use it in GitHub Desktop.
Save celsowhite/7e3022b5eb528a03aa87220b2de67d63 to your computer and use it in GitHub Desktop.
Sass snippet for when you need to do the same keyframe animation for different elements but use different colors.
// Setup a map for the color variables.
$colorMap: (firstBlue: #297189, secondBlue: #BEEBEB, thirdBlue: #A2DAE0, fourthBlue: #81C4D4, fifthBlue: #5099AA);
// Loop through each to create the selector and keyframes function
@each $colorName, $color in $colorMap {
// Selector for this specific svg component.
.logo_transition.fill_#{$colorName} {
animation: fill_#{$colorName} 1s 1s linear forwards;
}
// Keyframes
@keyframes fill_#{$colorName} {
to {
fill: $color;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment