Skip to content

Commit 210af27

Browse files
committed
feat(standalone): add map splitting function
1 parent 3d00d16 commit 210af27

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

projects/igniteui-angular/src/lib/core/styles/themes/_standalone.scss

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,45 @@
5353
}
5454
}
5555
}
56+
57+
/// Splits a map into two separate maps based on a list of keys
58+
///
59+
/// @author Your Name
60+
///
61+
/// @param {Map} $map - The original map to split
62+
/// @param {List} $pick-keys - List of keys to include in the first returned map
63+
///
64+
/// @return {List} A list containing two maps:
65+
/// - First map contains key-value pairs where keys are in $pick-keys
66+
/// - Second map contains all remaining key-value pairs
67+
///
68+
/// @example scss
69+
/// $colors: (
70+
/// primary: blue,
71+
/// secondary: green,
72+
/// tertiary: yellow,
73+
/// quaternary: purple
74+
/// );
75+
///
76+
/// $result: split-map($colors, (primary, secondary));
77+
/// // $result[1] = (primary: blue, secondary: green)
78+
/// // $result[2] = (tertiary: yellow, quaternary: purple)
79+
@function split-map($map, $pick-keys) {
80+
$map-1: ();
81+
$map-2: ();
82+
83+
@each $key, $value in $map {
84+
$id: list.index($pick-keys, $key);
85+
86+
@if $id {
87+
$map-1: map.merge($map-1, ($key: $value));
88+
} @else {
89+
$map-2: map.merge($map-2, ($key: $value));
90+
}
91+
}
92+
93+
@return (
94+
$map-1,
95+
$map-2
96+
);
97+
}

0 commit comments

Comments
 (0)