Last active
December 17, 2015 11:19
Revisions
-
tybruffy renamed this gist
Mar 25, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tybruffy revised this gist
May 17, 2013 . 1 changed file with 46 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ Less.js Loop for manipulating adjacent siblings. Defaults to add the style to all X number of siblings as specified in the call. ```less .testcase { .adjacents-content() { display: inline; } .adjacents(4, ".item" ); } ``` Will output to ```css .testcase + .item { display: inline; } .testcase + .item + .item { display: inline; } .testcase + .item + .item + .item { display: inline; } .testcase + .item + .item + .item + .item { display: inline; } ``` Alternately you can target just a specific sibling: ```less .testcase { .adjacents-content() { display: inline; } .adjacents(4, ".item", false ); } ``` Outputs ```css .testcase + .item + .item + .item + .item { display: inline; } ``` -
tybruffy created this gist
May 17, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ .adjacents( @count, @item: "", @all: true, @name: "" ) when (@all) { @selector: ~"@{name} + @{item}"; .loop (@index) when (@index > 0) { (@selector) { .adjacents-content(); } .adjacents(@index - 1, @item, true, @selector ); } .loop (0) {} .loop(@count); } .adjacents( @count, @item: "", @all: true, @name: "" ) when not (@all) { @selector: ~"@{name} + @{item}"; .loop(@index) when(@index > 1) { .adjacents(@index - 1, @item, false, @selector ); } .loop (@index) when (@index = 1) { (@selector) { .adjacents-content(); } .adjacents(@index - 1, @item, false, @selector ); } .loop (0) {} .loop(@count); } .adjacents(0);