-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy path_utilities.scss
66 lines (57 loc) · 1.54 KB
/
_utilities.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@use 'sass:list';
@use 'sass:map';
// Map Increment
// -------------
/// Add map values together
/// @access private
/// @group private-utils
/// @param {map} $base -
/// Initial map to add values to
/// @param {map} $add -
/// Map of values to be added
/// @return {map} Map of values after incrementing
@function map-increment($base, $add) {
@each $key in map.keys($add) {
$value: map.get($add, $key);
@if $value {
$base-value: map.get($base, $key);
$new-value: if($base-value, $base-value + $value, $value);
$base: map.merge(
$base,
(
$key: $new-value,
)
);
}
}
@return $base;
}
// Join Multiple
// -------------
/// Extends the Sass `join()` function
/// to accept and combine any number of lists
/// @access private
/// @group private-utils
/// @param {list | 'space' | 'comma'} $lists... -
/// Any number of lists to be joined,
/// with an optional final argument describing
/// the desired list-separator ('space' or 'comma')
/// @return {list} Joined items in a single list
@function join-multiple($lists...) {
$return: list.nth($lists, 1);
$type: list.separator($return);
$last: list.nth($lists, -1);
$length: list.length($lists);
@if ($last == 'space') or ($last == 'comma') {
$length: $length - 1;
$type: $last;
}
@if ($length < 2) {
$error: 'Must provide at least 2 lists';
@return error($error, 'join-multiple');
}
@for $i from 2 through $length {
$return: list.join($return, list.nth($lists, $i), $type);
}
@return $return;
}