Skip to content

Instantly share code, notes, and snippets.

@micahgodbolt
Created July 15, 2014 18:11
Show Gist options
  • Save micahgodbolt/91bb8af1918a4bba87de to your computer and use it in GitHub Desktop.
Save micahgodbolt/91bb8af1918a4bba87de to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.0.rc.1)
// Compass (v1.0.0.alpha.20)
// ----
@mixin insert-context($target, $context, $order: before) {
$new-context: "";
@if $order == before {
$new-context: selector-nest($context, $target);
}
@else {
$new-context: selector-nest($target, $context);
}
foo: $new-context; /* testing selector-nest */
$new-selector: selector-replace(&, $target, $new-context);
@at-root #{$new-selector} {
@content;
}
}
.tabs {
.tab {
background: red;
&:hover {
background: white;
}
}
.tab-link {
color: white;
@include insert-context('.tab-link', '.tab:hover') {
color: red;
}
}
}
.tabs .tab {
background: red;
}
.tabs .tab:hover {
background: white;
}
.tabs .tab-link {
color: white;
foo: .tab:hover .tab-link;
/* testing selector-nest */
}
.tabs .tab:hover .tab-link, .tab:hover .tabs .tab-link {
color: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment