Skip to content

Commit

Permalink
✨ feat(_functions.scss): Add new function to convert list of properti…
Browse files Browse the repository at this point in the history
…es into property map
  • Loading branch information
Spiderpig86 committed Sep 28, 2022
1 parent ae26f16 commit 84fa95d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/internal/_functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ $DELIMETER: '-';
)
)
);
*/
@function get-with-extend($all-config, $keys...) {
$result: ();
Expand All @@ -100,3 +99,17 @@ $DELIMETER: '-';

@return $result;
}

/*
Converts a list of properties to a mapping where the key and value are the property
itself.
*/
@function to-property-map($properties) {
$result: ();

@each $property in $properties {
$result: map.set($result, $property, $property);
}

@return $result;
}
16 changes: 16 additions & 0 deletions tests/internal/_functions.spec.scss
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,19 @@
);
}
}

/*********************
* to-property-map() *
*********************/
@include describe('to-property-map()') {
@include it('should return mapping when given a valid list of properties') {
@include assert-equal(
functions.to-property-map((left, right, both)),
(
left: left,
right: right,
both: both,
)
);
}
}

0 comments on commit 84fa95d

Please sign in to comment.