Skip to content

Instantly share code, notes, and snippets.

@rymizuki
Created March 14, 2014 00:13
Show Gist options
  • Save rymizuki/9539803 to your computer and use it in GitHub Desktop.
Save rymizuki/9539803 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.2)
// Compass (v1.0.0.alpha.18)
// ----
$state-when--types: (
'active': ('&.is--active, &:active, &:hover'),
'current': ('&.is--current'),
'visible': ('&.is--visible')
) !global;
@mixin state-when ($states) {
@each $state in $states {
$selector: map-get($state-when--types, $state);
#{$selector} {
@content;
}
}
}
.example {
@include state-when('active') {
display: block;
};
}
.example2 {
$states: 'active', 'current';
@include state-when($states) {
background-color: red;
}
}
.example.is--active, .example:active, .example:hover {
display: block;
}
.example2.is--active, .example2:active, .example2:hover {
background-color: red;
}
.example2.is--current {
background-color: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment