Skip to content

Instantly share code, notes, and snippets.

@akfzambrana
Last active March 3, 2017 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save akfzambrana/67aef58710922a846aac145a5ecd2f28 to your computer and use it in GitHub Desktop.
Save akfzambrana/67aef58710922a846aac145a5ecd2f28 to your computer and use it in GitHub Desktop.
State color changes mixin
// ----
// 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
);
}
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