// @category utilities/lists // remove an index from a list // @function list-remove // @param $list {List} the list to remove from // @param $idx {Number} the index to remove // @param $separator {String} the separator to use [auto|comma|space] // @return $new-list {Boolean} the list with removed index @function list-remove($list: (), $idx: false, $separator: auto) { @return list-replace($list: $list, $idx: $idx, $value: nil, $separator: $separator); } // replace an index in a list // @function list-replace // @param $list {List} the list to replace from // @param $value {*} the value to replace (if nil, it's a removal) // @param $idx {Number} the index to replace // @param $separator {String} the separator to use [auto|comma|space] // @return $new-list {List} the list with replaced index @function list-replace($list: (), $idx: false, $value: nil, $separator: auto) { $list: -compass-list($list); // if no index was provided, just return the original list @if($idx == false) { @return $list; } $new-list: (); @for $i from 1 through length($list) { @if $i != $idx { $new-list: append($new-list, nth($list, $i), $separator); } @else if($value != nil) { $new-list: append($new-list, $value, $separator); } } @return $new-list; } // map collection items to conform to a well defined collection // this is primarily used to convert shorthand notations into symmetrical longhand notations // @function get-collection // @private // @param $list {List} input list // @param $components {List} list of components // @param $min {Number} the minimum length of the collection // @return $list {List} formatted collection // @usage: // $padding: get-collection(10px, $min: 2) => 10px 10px // $offset: get-collection($components: (1 2), $min: 4) => 1 2 1 2 @function get-collection($list: false, $components: false, $min: 1) { @if($list == false) { $list: $components; } @while(length($list) < $min) { $list: $list $list; } @return $list; }