Last active
March 3, 2017 17:01
-
-
Save akfzambrana/67aef58710922a846aac145a5ecd2f28 to your computer and use it in GitHub Desktop.
State color changes mixin
This file contains 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
// ---- | |
// Sass (v3.4.21) | |
// Compass (v1.0.3) | |
// ---- | |
$color-state-modifier: 10%; | |
@mixin state-color-changes($this-color, $properties...) { | |
@each $prop in $properties { | |
#{$prop}: $this-color; | |
} | |
&:hover { | |
@each $prop in $properties { | |
#{$prop}: darken($this-color, $color-state-modifier); | |
} | |
} | |
&:active { | |
@each $prop in $properties { | |
#{$prop}: lighten($this-color, $color-state-modifier); | |
} | |
} | |
} | |
button { | |
@include state-color-changes( | |
#f00, | |
background, | |
color | |
); | |
} | |
a { | |
@include state-color-changes( | |
#f0f, | |
color | |
); | |
} |
This file contains 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
button { | |
background: #f00; | |
color: #f00; | |
} | |
button:hover { | |
background: #cc0000; | |
color: #cc0000; | |
} | |
button:active { | |
background: #ff3333; | |
color: #ff3333; | |
} | |
a { | |
color: #f0f; | |
} | |
a:hover { | |
color: #cc00cc; | |
} | |
a:active { | |
color: #ff33ff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment