Skip to content

Commit

Permalink
refactor(map.pick-pattern()): add '^' start and '$' end string patt…
Browse files Browse the repository at this point in the history
…ern to pick values.
  • Loading branch information
sciborrudnicki committed Nov 7, 2023
1 parent a603ea4 commit 1100a95
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion map/pick/_pick.pattern.function.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
$result: ();
@each $pattern in append((), $pattern, comma, $patterns...) {
@if type-of($pattern) == string {
@if string.index($pattern, '*') {
@if list.index(string.index($pattern, '^', '$'), 1) {
$position: string.slice($pattern, 1, 1);
$pattern: string.replace($pattern, first, $position, '');
$result: map.deep-merge($result, key-substring($map, ($position: $pattern)));
} @else if string.index($pattern, '*') {
$result: map.deep-merge($result, key-substring($map, string.replace($pattern, first, '*', '')));
} @else if string.index($pattern, 'value:') or string.index($pattern, 'key:') {
$result: map.deep-merge($result, type($map, $pattern));
Expand All @@ -47,6 +51,18 @@
// ),
// ),
// basic: (
// '9971test': 1,
// '2test': 2,
// '3test': 3,
// '4test': 4,
// '5test': 5,

// 'test9971': 1,
// 'test2': 2,
// 'test3': 3,
// 'test4': 4,
// 'test5': 5,

// 'default.palette': (),

// 'palette.gray': (
Expand Down Expand Up @@ -133,3 +149,6 @@
// @debug pattern(map.get($-theme, basic), 'value:string,list');
// @debug pattern(map.get($-theme, basic), 'key:string,list');
// @debug pattern(map.get($-theme, basic), 'key,value:list,string'); // TODO

// @debug pattern(map.get($-theme, basic), '^test');
// @debug pattern(map.get($-theme, basic), '$test');

0 comments on commit 1100a95

Please sign in to comment.