- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Wed, 09 Dec 2020 19:17:18 +0000
- To: public-houdini-archive@w3.org
tabatkins has just created a new issue for https://github.com/w3c/css-houdini-drafts: == [css-typed-om] Inputs for the CSSColorValue constructors == I'm writing the spec for color values right now, and the overall structure is straightforward: a CSSColorValue superclass, and subclasses for each type of color function. I'm struggling a bit with the best design for the constructor arguments and/or the shorthand functions. Some arguments, like hue angles, are easy - they're just a CSSNumericValue that needs to match `<angle>`. But *most* of the arguments to color functions are percentages. Obviously I'll accept a CSSNumericValue that matches `<percentage>`, but I'd like easier ways to invoke these - writing `new CSSRGB(CSS.percent(10), CSS.percent(0), CSS.percent(100))` isn't great. In particular, I'd like to allow them to accept JS numbers, interpreting the range 0-1 as being equivalent to a percent between 0% and 100%, so you could instead write the preceding function as `new CSSRGB(.1, 0, 1)`. This would generally be unproblematic and straightforward, *except* that `rgb()` accepts `<number>` as well, in the range 0-255. And elsewhere in TypedOM (such as `new CSSScale()`), passing a raw JS number is equivalent to passing a `CSSUnitValue(x, "number")` (see the ["rectify a numberish value" algo](https://drafts.css-houdini.org/css-typed-om/#rectify-a-numberish-value)). So this leaves me with several possibilities, none of which I find *great*: 1. Always allow JS numbers in the color functions in the 0-1 range. There's no constructor form that's a direct equivalent to the `rgb(0, 128, 255)` syntax. 2. Allow JS numbers in the color functions in the 0-1 range, but also allow `CSSUnitValue(x, "number")` to be passed to CSSRGB, with the 0-255 range. 3. Don't allow JS numbers at all, only CSSNumericValues. CSSRGB accepts `CSSUnitValue(x, "number")` in the 0-255 range. 4. (Definitely bad, not doing this) Allow JS numbers in the 0-1 range for all the color functions *except* CSSRGB, allow them in the 0-255 range for CSSRGB (in addition to `CSSUnitValue(x, "number")`). 5. Same as (3), but also have shorthand functions like `CSS.rgb()` (akin to the `CSS.px()` family for numeric values) that act like (1). I'm considering going with (1), but (5) would be fine as well. I don't like the others very much. Anyone else have opinions? Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/1014 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 9 December 2020 19:17:20 UTC