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 is legacy #4

Closed
wants to merge 15 commits into from
Closed

color is legacy #4

wants to merge 15 commits into from

Conversation

SondraE
Copy link

@SondraE SondraE commented Nov 18, 2022

Description

(sass#1842)

Steps to test/reproduce

  • new file called legacy
  • tests to determine which colors are legacy

@SondraE SondraE changed the title added tests for legacy colors and non-legacy colors color is legacy Nov 18, 2022
Copy link

@dvdherron dvdherron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is on the right track Sondra. The format looks good. We will have to decide what tests to include (we probably won't test all color spaces?).

I think adding some error tests would be next here (look at some of the "error/too_few_args", "error/too_many_args", "error/type" tests in the project. A lot of these follow a similar pattern.)

spec/core_functions/color/legacy.hrx Outdated Show resolved Hide resolved

<===>
================================================================================
<===> srgb/input.scss

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we'll have to decide which of this need to be included to feel like we've covered enough cases. We probably won't need to test all of the color types.

SondraE and others added 2 commits November 18, 2022 11:47
Co-authored-by: david herron <41588129+dvdherron@users.noreply.github.com>
Copy link
Member

@stacyk stacyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SondraE looks great so far. I added some suggestions as I believe commas are no longer needed in the color notations.

I don't know how many color formats we will want to test but it may make sense to include something like:

  • a named color
  • hex color
  • maybe something with alpha in the legacy color space?

@@ -0,0 +1,182 @@
<===> options.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SondraE I don't know this for sure, but I am guessing the filename is_legacy.hrx would be preferred.

================================================================================
<===> hwb/input.scss
@use "sass:color";
a {b: color.is-legacy(hwb(0, 50%, 0%))}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(hwb(0, 50%, 0%))}
a {b: color.is-legacy(hwb(0 50% 0%))}

I believe Sass will support with or without commas

================================================================================
<===> hsl/input.scss
@use "sass:color";
a {b: color.is-legacy(hsl(110, 31%, 32%))}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(hsl(110, 31%, 32%))}
a {b: color.is-legacy(hsl(110 31% 32%))}

================================================================================
<===> srgb/input.scss
@use "sass:color";
a {b: color.is-legacy(srgb(115, 20, 210))}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mirisuzanne @dvdherron I've not really come across a lot with srgb used in a css notation like this before, but would it be more like:

a {b: color.is-legacy(color(srgb 0.45098 0.07843 0.823530))}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://css.oddbird.net/sass/color-spaces/proposal/#predefined-color-spaces

‘Predefined color spaces’ can be described using the color() function.
The predefined RGB spaces are:

  • srgb
  • srgb-linear
  • display-p3
  • a98-rgb
  • prophoto-rgb
  • rec2020

================================================================================
<===> srgb-linear/input.scss
@use "sass:color";
a {b: color.is-legacy(?????)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mirisuzanne @dvdherron @SondraE and same for here?

a {b: color.is-legacy(color(srgb-linear 0.45098 0.07843 0.823530))}

================================================================================
<===> prophoto-rgb/input.scss
@use "sass:color";
a {b: color.is-legacy(?????)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(?????)}
a {b: color.is-legacy(color(prophoto-rgb 0.42444 0.934918 0.190922))}

================================================================================
<===> a98-rgb/input.scss
@use "sass:color";
a {b: color.is-legacy(?????)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(?????)}
a {b: color.is-legacy(color(a98-rgb 0 1 0))}

================================================================================
<===> xyz-d50/input.scss
@use "sass:color";
a {b: color.is-legacy(?????)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(?????)}
a {b: color.is-legacy(color(xyz-d50 0.2005 0.14089 0.4472))}

================================================================================
<===> xyz-d65/input.scss
@use "sass:color";
a {b: color.is-legacy(?????)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(?????)}
a {b: color.is-legacy(color(xyz-d65 0.21661 0.14602 0.59452))}

================================================================================
<===> oklab/input.scss
@use "sass:color";
a {b: color.is-legacy(oklab(0.44027, 0.08818, -0.13386))}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(oklab(0.44027, 0.08818, -0.13386))}
a {b: color.is-legacy(oklab(0.44027 0.08818 -0.13386))}

I believe the commas would be an error for oklab, oklch,lab, and lch

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation
'
,--> sass:color
1 | @function color.is-legacy(rgb($amount $amount $amount)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of testing how the is-legacy() function works this is instead testing if the correct values are in the rgb() function. For is-legacy(), the "too few" error should be triggered with an empty function (color.is-legacy()) since this function only takes one argument ($color).

And then for all of the errors in this file, see Natalie's note about leaving the error message content blank.

<===>
================================================================================
<===> error/too_many_args/input.scss
a {b: color.is-legacy(rgb(0 255 0 15))}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. We're just trying to test is-legacy(). A "too many" args error should be triggered if we run this function with more than one color:

a {b: color.is-legacy(rgb(0 255 0), blue)}

(see the functions for blue() and blackness() for examples of errors for a single argument function)

input.scss 1:7 root stylesheet

<===> error/too_many_args/error-libsass
Error: wrong number of arguments (4 for 3) for `color.is-legacy'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this probably won't ever be implemented in libsass, we can omit any libsass error messages for this function and any entirely new function we write tests for. At the top of the file we have told the test runner to ignore libsass completely with :ignore_for: - libsass

<===>
================================================================================
<===> error/type/input.scss
a {b: color.is-legacy(rgb(0 255 red))}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(rgb(0 255 red))}
a {b: color.is-legacy(1)}

This function expects a color. A number would be the wrong type for the $color argument.

It might be good to also write an additional type test (error/type/string/input.scss) to make sure this errors if $color is a string (in quotes):

a {b: color.is-legacy("blue")}


<===>
================================================================================
<===> lch/input.scss

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<===> lch/input.scss
<===> named/input.scss

We could swap out one of the tests or add an additonal test called named. This will test that the function also works if the argument is explicitly named e.g. $color: lch(90.6 52.8 197)

================================================================================
<===> lch/input.scss
@use "sass:color";
a {b: color.is-legacy(lch(90.6 52.8 197))}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a {b: color.is-legacy(lch(90.6 52.8 197))}
a {b: color.is-legacy($color: lch(90.6 52.8 197))}

Copy link
Member

@stacyk stacyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SondraE These updates look good to me. I think this is ready to move forward....which I think means opening a PR on the sass/sass-spec repo, right @dvdherron? We are go over that tomorrow if so if you want.

@dvdherron
Copy link

@SondraE These updates look good to me. I think this is ready to move forward....which I think means opening a PR on the sass/sass-spec repo, right @dvdherron? We are go over that tomorrow if so if you want.

Missed this but it looks like PR was opened successfully? :) 🚀

SondraE and others added 10 commits December 2, 2022 13:48
This updates most tests for the currently-implemented chunk of the
Color 4 feature. A few tests that need more thorough reworking (such
as being moved out of `error/` for things that are no longer intended
to be errors) are marked as "todo" instead.

See sass#1828
See sass/sass#2831
This also skips a few color tests for the embedded host
@dvdherron dvdherron closed this Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants