Reputation: 519
I need to create a function to get a list of all unique items from multiple lists. Let's consider the following example:
$list-1: top, left, color;
$list-2: top, color, border;
@function get-unique-items($lists...) {
$unique-items: ();
// do the magic
@return $unique-items;
}
@debug get-unique-items($list-1, $list-2);
// should return: top, left, color, border
Can anyone do the magic?
Upvotes: 2
Views: 253
Reputation: 7800
You can do like this:
@function get-unique-items($lists...) {
$unique-items: ();
@each $list in $lists {
@each $item in $list {
@if not index($unique-items, $item) {
$unique-items: append($unique-items, $item, comma);
}
}
}
@return $unique-items;
}
Upvotes: 2