Skip to content

Instantly share code, notes, and snippets.

@lunelson
Created May 6, 2013 09:37
Show Gist options
  • Save lunelson/5524219 to your computer and use it in GitHub Desktop.
Save lunelson/5524219 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com, the Sass playground.
$body-blocks: p ul ol dl table pre blockquote figure img;
$heading-blocks: h1 h2 h3 h4 h5 h6;
@function proc($list) {
$arr: unquote("#{nth($list, 1)} + &");
@for $n from 2 through length($list) {
$arr: append($arr, unquote(", #{nth($list,$n)} + &"));
}
@return $arr;
}
.test {
value: proc($body-blocks);
}
h1 {
margin-bottom: 1em;
p + & {
margin-bottom: 0;
}
#{proc($body-blocks)} {
padding: 10px;
}
}
@mixin self-adjacent { & + & { @content; } }
@mixin adjacent($list:()) {
@if $list == () {
& + & { @content; }
} @else {
$arr: unquote("#{nth($list, 1)} + &");
@for $n from 2 through length($list) {
$arr: append($arr, unquote(", #{nth($list,$n)} + &"));
}
#{$arr} { @content; }
}
}
.test {
@include adjacent() {
color: blue;
}
@include adjacent($body-blocks) {
color: green;
}
}
.test {
value: p + & , ul + & , ol + & , dl + & , table + & , pre + & , blockquote + & , figure + & , img + &;
}
h1 {
margin-bottom: 1em;
}
p + h1 {
margin-bottom: 0;
}
p + h1, ul + h1, ol + h1, dl + h1, table + h1, pre + h1, blockquote + h1, figure + h1, img + h1 {
padding: 10px;
}
.test + .test {
color: blue;
}
p + .test, ul + .test, ol + .test, dl + .test, table + .test, pre + .test, blockquote + .test, figure + .test, img + .test {
color: green;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment