Skip to content

Instantly share code, notes, and snippets.

@DarbyBrown
Created June 23, 2015 14:56
Show Gist options
  • Save DarbyBrown/f855be9d9d20bef0e4de to your computer and use it in GitHub Desktop.
Save DarbyBrown/f855be9d9d20bef0e4de to your computer and use it in GitHub Desktop.
// ----
// Sass (v3.4.0.rc.1)
// Compass (v1.0.0.alpha.20)
// ----
@mixin context($old-context, $new-context) {
@at-root #{selector-replace(&, $old-context, $new-context)} {
@content;
}
}
@mixin parentState($states...) {
$parent: nth(nth(&, 1), (length(nth(&, 1))-1));
@each $state in $states {
@at-root #{selector-replace(&, $parent, ($parent#{$state}))} {
@content;
}
}
}
.tabs {
.tab {
background: red;
&:hover {
background: white;
}
.tab-link {
color: white;
@include context('.tab', '.tab:hover') {
color: red;
}
@include parentState(':hover', '.active') {
color: pink;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment