Skip to content

Commit

Permalink
fix(validator): ensure is-color function handles additional color for…
Browse files Browse the repository at this point in the history
…mats
  • Loading branch information
Marinerer committed Jul 12, 2024
1 parent 7feb5d3 commit 9abac36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion functions/_validator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@
/// -----------------------------------------------------
@function is-color($color) {
// currentColor, var(--color-blue);
@return type-of($color) == color or $color == currentColor or str-slice($color, 1, 6) == 'var(--';
@if type-of($color) == color or $color == currentColor {
@return true;
} @else if type-of($color) == 'string' and str-slice($color, 1, 6) == 'var(--' {
@return true;
} @else {
@return false
}
}
7 changes: 7 additions & 0 deletions test/validator.test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
@include it('is-color') {
@include assert-equal(is-color(red), true);
@include assert-equal(is-color(rgba(0, 0, 0, 0)), true);
@include assert-equal(is-color(#000), true);
@include assert-equal(is-color(currentColor), true);
@include assert-equal(is-color(#00000000), true);
@include assert-equal(is-color(transparent), true);
@include assert-equal(is-color(20), false);
@include assert-equal(is-color('currentColor'), true);
@include assert-equal(is-color(var(--color-blue)), true);
}
}

0 comments on commit 9abac36

Please sign in to comment.