From 9f67360dbbd2ebf98c725bdda1f0422f5ebed06e Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 17 Dec 2020 15:19:52 -0800 Subject: [PATCH] [Angle Units] Mark the proposal as accepted See #2904 --- {proposal => accepted}/angle-units.md | 0 spec/built_in_modules/color.md | 22 ++++++++++++------ spec/functions.md | 33 ++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 10 deletions(-) rename {proposal => accepted}/angle-units.md (100%) diff --git a/proposal/angle-units.md b/accepted/angle-units.md similarity index 100% rename from proposal/angle-units.md rename to accepted/angle-units.md diff --git a/spec/built_in_modules/color.md b/spec/built_in_modules/color.md index 63d0130cce..fca0dd17d8 100644 --- a/spec/built_in_modules/color.md +++ b/spec/built_in_modules/color.md @@ -92,6 +92,13 @@ This function is also available as a global function named `adjust-color()`. * If `$hue` isn't a number or null, throw an error. +* If `$hue` is a number and it has units that aren't [compatible] with `deg`, + throw an error. + + > Unitless numbers are allowed. + + [compatible]: ../types/number.md#compatible-units + * If any of `$red`, `$green`, or `$blue` aren't null: * If any of `$hue`, `$saturation`, `$lightness`, `$whiteness`, or `$blackness` @@ -115,8 +122,8 @@ This function is also available as a global function named `adjust-color()`. * If either `$whiteness` or `$blackness` aren't null, throw an error. - * If either `$saturation` or `$lightness` aren't either null or numbers - between -100 and 100 (inclusive), throw an error. + * If either `$saturation` or `$lightness` aren't either null or numbers with + unit `%` between -100% and 100% (inclusive), throw an error. * Let `hue`, `saturation`, and `lightness` be the result of calling `hue($color)`, `saturation($color)`, and `lightness($color)` respectively. @@ -124,10 +131,10 @@ This function is also available as a global function named `adjust-color()`. * If `$hue` isn't null, set `hue` to `hue + $hue`. * If `$saturation` isn't null, set `saturation` to `saturation + $saturation` - clamped between 0 and 100. + clamped between 0% and 100%. * If `$lightness` isn't null, set `lightness` to `lightness + $lightness` - clamped between 0 and 100. + clamped between 0% and 100%. * Return the result of calling [`hsl()`][] with `hue`, `saturation`, `lightness`, and `alpha`. @@ -393,13 +400,13 @@ This function is also available as a global function named `hue()`. * If any of `$hue`, `$whiteness`, `$blackness`, or `$alpha` aren't numbers, throw an error. - * If `$hue` has any units other than `deg`, throw an error. + * Let `hue` be the result of [converting] `$hue` to `deg` allowing unitless. + + * Set `hue` to `(hue % 360deg) / 60deg`. * If either of `$whiteness` or `$blackness` don't have unit `%` or aren't between `0%` and `100%` (inclusive), throw an error. - * Let `hue` be `($hue % 360) / 60` without units. - * Let `whiteness` be `$whiteness / 100%`. * Let `blackness` be `$blackness / 100%`. @@ -420,6 +427,7 @@ This function is also available as a global function named `hue()`. * Return a color with the given `red`, `green`, `blue`, and `alpha` channels. + [converting]: ../types/number.md#converting-a-number-to-a-unit [percent-converting]: #percent-converting-a-number [to RGB]: https://www.w3.org/TR/css-color-4/#hwb-to-rgb diff --git a/spec/functions.md b/spec/functions.md index c93f358029..26f0e1b336 100644 --- a/spec/functions.md +++ b/spec/functions.md @@ -8,6 +8,7 @@ * [Syntax](#syntax) * [Semantics](#semantics) * [Global Functions](#global-functions) + * [`adjust-hue()`](#adjust-hue) * [`alpha()`](#alpha) * [`rgb()` and `rgba()`](#rgb-and-rgba) * [`hsl()` and `hsla()`](#hsl-and-hsla) @@ -93,6 +94,27 @@ To evaluate a `FunctionCall` `call`: > introduced. These global aliases should be avoided by stylesheet authors if > possible. +### `adjust-hue()` + +``` +adjust-hue($color, $degrees) +``` + +* If `$color` isn't a color or `$degrees` isn't a number, throw an error. + +* Let `degrees` be the result of [converting] `$degrees` to `deg` allowing + unitless. + +* Let `saturation` and `lightness` be the result of calling + [`color.saturation($color)`] and [`color.lightness($color)`], respectively. + +* Return the result of calling [`hsl()`] with `degree`, `saturation`, + `lightness`, and `$color`'s alpha channel. + +[`hsl()`]: #hsl-and-hsla +[`color.saturation($color)`]: built_in_modules/color.md#saturation +[`color.lightness($color)`]: built_in_modules/color.md#lightness + ### `alpha()` * ``` @@ -233,11 +255,15 @@ plain CSS function named `"hsl"` that function is named `"hsla"` instead. * If any of `$hue`, `$saturation`, `$lightness`, or `$alpha` aren't numbers, throw an error. - * Let `hue` be `($hue % 360) / 60` without units. + * Let `hue` be the result of [converting] `$hue` to `deg` allowing unitless. + + * Set `hue` to `(hue % 360deg) / 60deg`. + + * If `$saturation` and `$lightness` don't have unit `%`, throw an error. * Let `saturation` and `lightness` be the result of clamping `$saturation` and - `$lightness`, respectively, between 0 and 100 and dividing by 100. - + `$lightness`, respectively, between `0%` and `100%` and dividing by `100%`. + * Let `red`, `green`, and `blue` be the result of converting `hue`, `saturation`, and `lightness` [to RGB][]. @@ -248,6 +274,7 @@ plain CSS function named `"hsl"` that function is named `"hsla"` instead. * Return a color with the given `red`, `green`, `blue`, and `alpha` channels. + [converting]: types/number.md#converting-a-number-to-a-unit [to RGB]: https://www.w3.org/TR/css-color-4/#hsl-to-rgb * ```