Skip to content

Instantly share code, notes, and snippets.

@aolko
Created March 15, 2016 00:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aolko/cc5909e59562741a79ab to your computer and use it in GitHub Desktop.
Save aolko/cc5909e59562741a79ab to your computer and use it in GitHub Desktop.
Simple attribute module selector generator for Sass
[am-button] {
content: "";
}
[am-button~="large"] {
content: "";
}
[am-button~="large rounded"] {
content: "";
}
[am-row] {
content: "";
}
[am-column] {
content: "";
}
[am-column~="1/12"] {
content: "";
}
// ----
// 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