-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from krypton225/functions
feat(functions-list): ✨ add merge function to merge any list…
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@charset "UTF-8"; | ||
|
||
// @description | ||
// * merge function. | ||
// * This function merges lists together and return all in a one list. | ||
|
||
// @access private | ||
|
||
// @version 1.0.0 | ||
|
||
// @author Khaled Mohamed | ||
|
||
// @license MIT | ||
|
||
// @repository: https://github.com/krypton225/sass-pire | ||
|
||
// @namespace list | ||
|
||
// @module list/merge | ||
|
||
// @dependencies: | ||
// * - list.join (SASS function). | ||
// * - flatten-list (function). | ||
|
||
// @param {List} $list... | ||
// * A group of lists that may contain nested lists. | ||
|
||
// @throw {Exception} | ||
// * Throws an exception if the provided parameter is not a lists. | ||
|
||
// @example | ||
// * .example { | ||
// * content: merge((2, 4, 5, (12, 5, 6)), (22, 38), (44, ((323)))); | ||
// * } | ||
|
||
// @output | ||
// * .example { | ||
// * content: 2 4 5 12 5 6 22 38 44 323; | ||
// * } | ||
|
||
// @return {List} - Returns a merged list. | ||
|
||
@use "sass:list"; | ||
@use "./flatten-list" as func; | ||
|
||
@function merge($lists...) { | ||
$merged-list: (); | ||
|
||
@each $value in $lists { | ||
@if type-of($value) != list { | ||
@error "merge function only accepts lists."; | ||
} | ||
|
||
$flatten-one-list: func.flatten($value); | ||
$merged-list: list.join($merged-list, $flatten-one-list, space); | ||
} | ||
|
||
@return $merged-list; | ||
} |