Created
September 17, 2014 01:40
-
-
Save jaggy/92982b54afada0710c22 to your computer and use it in GitHub Desktop.
My Sass Toolbox
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
/* | |
|-------------------------------------------------------------------------- | |
| List: Prefix | |
|-------------------------------------------------------------------------- | |
| | |
| Add a prefix to all the list items | |
| | |
| @param list $list | |
| @param string $string | |
| @return list | |
*/ | |
@function prefixify($list, $string: '') | |
{ | |
$result: (); | |
@for $i from 1 through length($list) { | |
$value: nth($list, $i); | |
$result: append($result, $string + $value); | |
} | |
@return $result; | |
} | |
/* | |
|-------------------------------------------------------------------------- | |
| List: Implode | |
|-------------------------------------------------------------------------- | |
| | |
| Join a list with a separator. Good for making selectors! | |
| http://hugogiraudel.com/2013/08/08/advanced-sass-list-functions/ | |
| | |
| @param list $list | |
| @param string $glue | |
| @param boolean $is-nested | |
| @return list | |
*/ | |
@function implode($list, $glue: '', $is-nested: false) | |
{ | |
$result: null; | |
@for $i from 1 through length($list) { | |
$e: nth($list, $i); | |
@if type-of($e) == list { | |
$result: $result#{to-string($e, $glue, true)}; | |
} | |
@else { | |
$result: if($i != length($list) or $is-nested, $result#{$e}#{$glue}, $result#{$e}); | |
} | |
} | |
@return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment