Last active
August 29, 2015 14:17
-
-
Save SidIcarus/b24ec2a9329825d8cc6f to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p class="qualifyClassname-p"> | |
Hello. I am a p tag; | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.12) | |
// Compass (v1.0.3) | |
// ---- | |
@function first-char($str) { @return str-slice($str, 1, 1); } | |
@function remove-first-char($str) { @return str-slice($str, 2, str-length($str)); } | |
@function has-prefix-selector($str) { | |
$prefix-selectors: ".", "#"; | |
@return index($prefix-selectors, first-char($str)); | |
} | |
@function unprefix-parent($str) { | |
@if has-prefix-selector($str) { $str: remove-first-char($str); } | |
@return $str; | |
} | |
@mixin qualify($selector) { @at-root #{$selector + &} { @content; } } | |
@mixin true-qualify($type, $name) { | |
$selector: $type + $name + unprefix-parent(#{&}); | |
@at-root #{$selector} { @content; } | |
} | |
$prefix: 'login-'; | |
$class: '.'; | |
$class-prefix: $class + $prefix; | |
$id: '#'; | |
$id-prefix: $id + $prefix; | |
@mixin tq($type, $selector) { $parent: #{&}; | |
// color: gray; | |
@include true-qualify($type, $selector) { context: $parent; } | |
p { $parent: #{&}; | |
// color: green; | |
@include true-qualify($type, $selector) { context: $parent; } | |
.div { $parent: #{&}; | |
// color: red; | |
@include true-qualify($type, $selector) { context: $parent; } | |
} | |
} | |
} | |
@mixin q($selector) { $parent: #{&}; | |
// color: black; | |
@include qualify($selector) { context: $parent; } | |
p { $parent: #{&}; | |
// color: blue; | |
@include qualify($selector) { context: $parent; } | |
.div { $parent: #{&}; | |
// color: yellow; | |
@include qualify($selector) { context: $parent; } | |
} | |
} | |
} | |
nav { | |
@include tq($class, $prefix); | |
@include tq($id, $prefix); | |
@include q($class-prefix); | |
@include q($id-prefix); | |
} | |
.true-qualify { @include tq($class, $prefix); } | |
.qualify { @include q($class-prefix); } | |
#true-qualify { @include tq($id, $prefix); } | |
#qualify { @include q($id-prefix); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.login-nav { context: nav; } | |
.login-nav p { context: nav p; } | |
.login-nav p .div { context: nav p .div; } | |
#login-nav { context: nav; } | |
#login-nav p { context: nav p; } | |
#login-nav p .div { context: nav p .div; } | |
.login-nav { context: nav; } | |
.login-nav p { context: nav p; } | |
.login-nav p .div { context: nav p .div; } | |
#login-nav { context: nav; } | |
#login-nav p { context: nav p; } | |
#login-nav p .div { context: nav p .div; } | |
.login-true-qualify { context: .true-qualify; } | |
.login-true-qualify p { context: .true-qualify p; } | |
.login-true-qualify p .div { context: .true-qualify p .div; } | |
.login-.qualify { context: .qualify; } | |
.login-.qualify p { context: .qualify p; } | |
.login-.qualify p .div { context: .qualify p .div; } | |
#login-true-qualify { context: #true-qualify; } | |
#login-true-qualify p { context: #true-qualify p; } | |
#login-true-qualify p .div { context: #true-qualify p .div; } | |
#login-#qualify { context: #qualify; } | |
#login-#qualify p { context: #qualify p; } | |
#login-#qualify p .div { context: #qualify p .div; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p class="qualifyClassname-p"> | |
Hello. I am a p tag; | |
</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment