Created
March 15, 2016 00:03
-
-
Save aolko/cc5909e59562741a79ab to your computer and use it in GitHub Desktop.
Simple attribute module selector generator for Sass
This file contains hidden or 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
[am-button] { | |
content: ""; | |
} | |
[am-button~="large"] { | |
content: ""; | |
} | |
[am-button~="large rounded"] { | |
content: ""; | |
} | |
[am-row] { | |
content: ""; | |
} | |
[am-column] { | |
content: ""; | |
} | |
[am-column~="1/12"] { | |
content: ""; | |
} |
This file contains hidden or 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.4) | |
// Compass (v1.0.1) | |
// ---- | |
@mixin am($args) { | |
@if length($args) == 1 { | |
[am-#{$args}] { | |
@content; | |
} | |
} | |
@else { | |
$val: (); | |
@for $i from 2 through length($args) { | |
$val: append($val, nth($args, $i)); | |
} | |
[am-#{nth($args, 1)}~="#{$val}"] { | |
@content; | |
} | |
} | |
} | |
// Usage | |
@include am(button) { | |
content: ""; | |
} | |
@include am(button large) { | |
content: ""; | |
} | |
@include am(button large rounded) { | |
content: ""; | |
} | |
@include am(row) { | |
content: ""; | |
} | |
@include am(column) { | |
content: ""; | |
} | |
@include am(column "1/12") { | |
content: ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment