Skip to content

Commit

Permalink
feat(validation): add list support
Browse files Browse the repository at this point in the history
  • Loading branch information
borisdamevin committed Apr 22, 2024
1 parent 1172e9e commit 0cd69d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion __tests__/functions.spec.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TEST //
// ============================================================================================= //

@use 'pkg:sass-true' as *;
@use "pkg:sass-true" as *;
@use "./tokens";
@use "../src/functions";

Expand Down
2 changes: 1 addition & 1 deletion __tests__/mixins.spec.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TEST //
// ============================================================================================= //

@use 'pkg:sass-true' as *;
@use "pkg:sass-true" as *;
@use "./tokens";
@use "../src/mixins";
@use "../src/functions";
Expand Down
4 changes: 2 additions & 2 deletions src/_functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
///
/// Validates a user-provided theme's token and throws an error if tokens are invalid.
///
/// @param {Map} $reference - A map of reference tokens.
/// @param {List|Map} $reference - A list of map of reference tokens.
/// @param {Map} $tokens - A map of theme's tokens.
/// @param {String} $component - The component name.
///
/// @return {Map} The validated theme map.
///
@function validation($reference, $tokens, $component: null) {
$keys: map.keys($reference);
$keys: if(type.is-map($reference), map.keys($reference), $reference);
$unsupported-tokens: ();

@each $key, $value in $tokens {
Expand Down
9 changes: 6 additions & 3 deletions src/color/__tests__/mixins.spec.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// TEST //
// ============================================================================================= //

@use 'pkg:sass-true' as *;
@use "pkg:sass-true" as *;
@use "../../../index" with (
$color: (
"tokens": (
"primary": #006ea9
"primary",
"secondary"
)
)
);
Expand All @@ -19,14 +20,16 @@
@include output(false) {
.test {
@include mixins.theme((
"primary": darkcyan
"primary": darkcyan,
"secondary": darkorange
));
}
}

@include expect(false) {
.test {
--mg-color-primary: darkcyan;
--mg-color-secondary: darkorange;
}
}
}
Expand Down

0 comments on commit 0cd69d9

Please sign in to comment.