Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Color 4] Add tests for lab() #1928

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spec/core_functions/color/hsl/error/one_arg.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Error: $channels: Expected lightness "var(--foo) / 0.4" to be a number.
a {b: hsl(append((), 0 100% 100%, $separator: slash))}

<===> slash_list/too_few_elements/error
Error: Only 2 slash-separated elements allowed, but 1 was passed.
Error: $channels: Only 2 slash-separated elements allowed, but 1 was passed.
,
1 | a {b: hsl(append((), 0 100% 100%, $separator: slash))}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -173,7 +173,7 @@ Error: Only 2 slash-separated elements allowed, but 1 was passed.
a {b: hsl(list.slash(0 100% 100%, 0.4, 1))}

<===> slash_list/too_many_elements/error
Error: Only 2 slash-separated elements allowed, but 3 were passed.
Error: $channels: Only 2 slash-separated elements allowed, but 3 were passed.
,
2 | a {b: hsl(list.slash(0 100% 100%, 0.4, 1))}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
27 changes: 27 additions & 0 deletions spec/core_functions/color/lab/_utils.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@use 'sass:color';
@use 'sass:list';
@use 'sass:meta';

@function -real-channel($color, $channel) {
@if color.is-missing($color, $channel) {
@return none;
} @else {
@return color.channel($color, $channel);
}
}

@mixin inspect($color) {
a {
value: $color;
@if meta.type-of($color) == string {
type: string;
} @else {
channels: list.slash(
-real-channel($color, 'lightness')
-real-channel($color, 'a')
-real-channel($color, 'b'),
-real-channel($color, 'alpha')
);
}
}
}
145 changes: 145 additions & 0 deletions spec/core_functions/color/lab/alpha.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<===> transparent/input.scss
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(0 255 127 / 0));

<===> transparent/output.css
a {
value: lab(0% 255 127 / 0);
channels: 0% 255 127 / 0;
}

<===>
================================================================================
<===> opaque/input.scss
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(1% 2 3 / 1));

<===> opaque/output.css
a {
value: lab(1% 2 3);
channels: 1% 2 3 / 1;
}

<===>
================================================================================
<===> partial/input.scss
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(1% 2 3 / 0.4));

<===> partial/output.css
a {
value: lab(1% 2 3 / 0.4);
channels: 1% 2 3 / 0.4;
}

<===>
================================================================================
<===> percent/input.scss
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(1% 2 3 / 40%));

<===> percent/output.css
a {
value: lab(1% 2 3 / 0.4);
channels: 1% 2 3 / 0.4;
}

<===>
================================================================================
<===> named/input.scss
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab($channels: 1% 2 3 / 0.4));

<===> named/output.css
a {
value: lab(1% 2 3 / 0.4);
channels: 1% 2 3 / 0.4;
}

<===>
================================================================================
<===> slash_list/input.scss
@use "sass:list";
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(list.slash(1% 2 3, 0.4)));

<===> slash_list/output.css
a {
value: lab(1% 2 3 / 0.4);
channels: 1% 2 3 / 0.4;
}

<===>
================================================================================
<===> none/slash/b/input.scss
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(1% 2 none / 0.4));

<===> none/slash/b/output.css
a {
value: lab(1% 2 none / 0.4);
channels: 1% 2 none / 0.4;
}

<===>
================================================================================
<===> none/slash/alpha/input.scss
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(1% 2 3 / none));

<===> none/slash/alpha/output.css
a {
value: lab(1% 2 3 / none);
channels: 1% 2 3 / none;
}

<===>
================================================================================
<===> none/slash/b_and_alpha/input.scss
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(1% 2 none / none));

<===> none/slash/b_and_alpha/output.css
a {
value: lab(1% 2 none / none);
channels: 1% 2 none / none;
}

<===>
================================================================================
<===> none/slash_list/b/input.scss
@use 'sass:list';
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(list.slash(1% 2 none, 0.4)));

<===> none/slash_list/b/output.css
a {
value: lab(1% 2 none / 0.4);
channels: 1% 2 none / 0.4;
}

<===>
================================================================================
<===> none/slash_list/alpha/input.scss
@use 'sass:list';
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(list.slash(1% 2 3, none)));

<===> none/slash_list/alpha/output.css
a {
value: lab(1% 2 3 / none);
channels: 1% 2 3 / none;
}

<===>
================================================================================
<===> none/slash_list/b_and_alpha/input.scss
@use 'sass:list';
@use 'core_functions/color/lab/utils';
@include utils.inspect(lab(list.slash(1% 2 none, none)));

<===> none/slash_list/b_and_alpha/output.css
a {
value: lab(1% 2 none / none);
channels: 1% 2 none / none;
}
Loading