Skip to content

Instantly share code, notes, and snippets.

@gisu
Created December 3, 2014 02:19
Show Gist options
  • Save gisu/e0035e021402f82f0698 to your computer and use it in GitHub Desktop.
Save gisu/e0035e021402f82f0698 to your computer and use it in GitHub Desktop.
/**
* Smart Append Selectors
*
* @param {string} $name - Name of the Tag
* @param {string|bool} $mod - Name of the modifier
* @param {bool} $context - For nested selector
* @param {string} $name - Name from the Tag
*/
@mixin append($tag, $mod: false, $context: false) {
@if $context {
@if $mod {
> [#{$tag}~='#{$mod}'] {
@content;
}
} @else {
> [#{$tag}] {
@content;
}
}
} @else {
@at-root {
@if $mod {
[#{$tag}~='#{$mod}'] {
@content;
}
} @else {
[#{$tag}] {
@content;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment