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

Add specs for passing non-deg units to hwb's hue #1806

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions spec/core_functions/color/adjust_hue.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ a {
}

<===> units/unknown/warning
DEPRECATION WARNING: $null: Passing a unit other than deg (60in) is deprecated.
DEPRECATION WARNING: $degrees: Passing a unit other than deg (60in) is deprecated.

To preserve current behavior: $null / 1in
To preserve current behavior: $degrees / 1in

See https://sass-lang.com/d/color-units

Expand All @@ -137,13 +137,13 @@ a {
}

<===> units/angle/warning
DEPRECATION WARNING: $null: Passing a unit other than deg (60rad) is deprecated.
DEPRECATION WARNING: $degrees: Passing a unit other than deg (60rad) is deprecated.

You're passing 60rad, which is currently (incorrectly) converted to 60deg.
Soon, it will instead be correctly converted to 3437.7467707849deg.

To preserve current behavior: $null * 1deg/1rad
To migrate to new behavior: 0deg + $null
To preserve current behavior: $degrees * 1deg/1rad
To migrate to new behavior: 0deg + $degrees

See https://sass-lang.com/d/color-units

Expand Down
52 changes: 52 additions & 0 deletions spec/core_functions/color/hwb/three_args/units.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,55 @@ a {b: color.hwb(0deg, 30%, 40%)}
a {
b: #994d4d;
}

<===>
================================================================================
<===> hue/rad/input.scss
@use 'sass:color';
a {b: color.hwb(1rad, 30%, 40%)}

<===> hue/rad/output.css
a {
b: #994e4d;
}

<===> hue/rad/warning
DEPRECATION WARNING: $hue: Passing a unit other than deg (1rad) is deprecated.

You're passing 1rad, which is currently (incorrectly) converted to 1deg.
Soon, it will instead be correctly converted to 57.2957795131deg.

To preserve current behavior: $hue * 1deg/1rad
To migrate to new behavior: 0deg + $hue
Copy link
Member

Choose a reason for hiding this comment

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

Does 0dev + $hue mean that users will have to always do this until dart-sass 2.0.0?
I wonder if we should give another alternative like doing the calculation to deg and saying

To migrate to new behavior, either:
 - force-cast to deg units with: 0deg + $hue
 - manually update to deg units: 57.3 deg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once we release Phase 2 non-deg angles will be automatically converted to degrees. 0deg + $hue is just a stop-gap measure to force the conversion before Phase 2 is released.

I'm always wary about suggesting literal values in these, because I expect a lot of the time the argument comes from something that is itself dynamic and so can't be reliably replaced by a single value.


See https://sass-lang.com/d/color-units

,
2 | a {b: color.hwb(1rad, 30%, 40%)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet

<===>
================================================================================
<===> hue/non_angle/input.scss
@use 'sass:color';
a {b: color.hwb(1in, 30%, 40%)}

<===> hue/non_angle/output.css
a {
b: #994e4d;
}

<===> hue/non_angle/warning
DEPRECATION WARNING: $hue: Passing a unit other than deg (1in) is deprecated.

To preserve current behavior: $hue / 1in

See https://sass-lang.com/d/color-units

,
2 | a {b: color.hwb(1in, 30%, 40%)}
| ^^^^^^^^^^^^^^^^^^^^^^^^
'
input.scss 2:7 root stylesheet