Skip to content

Commit

Permalink
[Color 4] Add tests for oklab()
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Sep 28, 2023
1 parent b03c91e commit 915a319
Show file tree
Hide file tree
Showing 7 changed files with 742 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/core_functions/color/oklab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Some of the same behavior tested for `lab()` applies to this function as well,
but for terseness' sake isn't tested explicitly.
27 changes: 27 additions & 0 deletions spec/core_functions/color/oklab/_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')
);
}
}
}
120 changes: 120 additions & 0 deletions spec/core_functions/color/oklab/alpha.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<===> transparent/input.scss
@use 'core_functions/color/oklab/utils';
@include utils.inspect(oklab(0 255 127 / 0));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 comments on commit 915a319

Please sign in to comment.