This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(theme): Added validation mixin to validate provided theme config…
…uration keys This mixin is used to validate provided theme configuration inside theme() mixin implementation. PiperOrigin-RevId: 345511907
- Loading branch information
1 parent
dd4670b
commit 1c156d6
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@use '../theme'; | ||
|
||
$origin-theme: ( | ||
one: 1, | ||
two: '22', | ||
three: 3px, | ||
four: ( | ||
x: 1, | ||
y: 2, | ||
), | ||
); | ||
|
||
// Should validate when subset of keys are provided. | ||
@include theme.validate-keys( | ||
$origin-theme, | ||
( | ||
two: '22', | ||
three: 3px, | ||
) | ||
); | ||
|
||
// Should validate when theme configuration is empty. | ||
@include theme.validate-keys($origin-theme, ()); | ||
|
||
// Should validate when nested theme keys are provided. | ||
@include theme.validate-keys( | ||
$origin-theme, | ||
( | ||
four: ( | ||
x: 11, | ||
y: 22, | ||
), | ||
) | ||
); | ||
|
||
// Should throw error when unsupported key (i.e., foobar) is provided. | ||
.test { | ||
@include theme.validate-keys( | ||
$origin-theme, | ||
( | ||
foobar: 66px, | ||
), | ||
$test-only: true | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters