Skip to content

Commit 1100a95

Browse files
refactor(map.pick-pattern()): add '^' start and '$' end string pattern to pick values.
1 parent a603ea4 commit 1100a95

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

map/pick/_pick.pattern.function.scss

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
$result: ();
2121
@each $pattern in append((), $pattern, comma, $patterns...) {
2222
@if type-of($pattern) == string {
23-
@if string.index($pattern, '*') {
23+
@if list.index(string.index($pattern, '^', '$'), 1) {
24+
$position: string.slice($pattern, 1, 1);
25+
$pattern: string.replace($pattern, first, $position, '');
26+
$result: map.deep-merge($result, key-substring($map, ($position: $pattern)));
27+
} @else if string.index($pattern, '*') {
2428
$result: map.deep-merge($result, key-substring($map, string.replace($pattern, first, '*', '')));
2529
} @else if string.index($pattern, 'value:') or string.index($pattern, 'key:') {
2630
$result: map.deep-merge($result, type($map, $pattern));
@@ -47,6 +51,18 @@
4751
// ),
4852
// ),
4953
// basic: (
54+
// '9971test': 1,
55+
// '2test': 2,
56+
// '3test': 3,
57+
// '4test': 4,
58+
// '5test': 5,
59+
60+
// 'test9971': 1,
61+
// 'test2': 2,
62+
// 'test3': 3,
63+
// 'test4': 4,
64+
// 'test5': 5,
65+
5066
// 'default.palette': (),
5167

5268
// 'palette.gray': (
@@ -133,3 +149,6 @@
133149
// @debug pattern(map.get($-theme, basic), 'value:string,list');
134150
// @debug pattern(map.get($-theme, basic), 'key:string,list');
135151
// @debug pattern(map.get($-theme, basic), 'key,value:list,string'); // TODO
152+
153+
// @debug pattern(map.get($-theme, basic), '^test');
154+
// @debug pattern(map.get($-theme, basic), '$test');

0 commit comments

Comments
 (0)