d3-color icon indicating copy to clipboard operation
d3-color copied to clipboard

HWB colour space + CSS Level 4 syntax

Open Parcly-Taxel opened this issue 6 years ago • 5 comments

This will fix #61.

I made a notebook with a picker for this space here.

Parcly-Taxel avatar Mar 10 '20 17:03 Parcly-Taxel

@mbostock I think this is ready to merge. This will serve as another pull request to include for my CS3282 module.

Parcly-Taxel avatar Mar 23 '20 04:03 Parcly-Taxel

Do any browsers support this yet? I’d be more inclined to add it if it had browser support.

mbostock avatar Mar 23 '20 06:03 mbostock

Do any browsers support this yet? I’d be more inclined to add it if it had browser support.

@mbostock As far as I know, the CSS Color Module Level 4, which includes HWB, is only a working draft and is not supported by any browser yet. This is why my Observable notebook converts HWB to RGB to insert into the displayed swatch.

However, this D3 module currently does not support some CSS colour formats that are supported by browsers now. Specifically, for the RGB space, all possible combinations of the following are allowed:

  • rgb()/rgba()
  • percentages/raw numbers for the colour channels
  • presence/absence of opacity, and percentage/raw number for that opacity
  • commas/commaless notation (spaces between the colour channels, slash to separate opacity)

Analogous support also exists for the HSL space, with units allowed for the hue. See below:

p {
  color: rgb(73.7 76.7 77.7 / 0.7);
  color: hsl(3.80rad 100% 50% / 70%);
}

I've pushed a commit that adds support for all of the above syntax.

Parcly-Taxel avatar Mar 26 '20 07:03 Parcly-Taxel

Do any browsers support this yet? I’d be more inclined to add it if it had browser support.

Safari added support for the lch notation (that d3-color already supports: https://caniuse.com/mdn-css_types_color_lch), and for the hwb notation: https://caniuse.com/mdn-css_types_color_hwb in their v15 (they are the only ones that have implemented those 2 notations for now).

And it seems that most browsers have implemented the syntax rgb(R G B / A): https://caniuse.com/mdn-css_types_color_rgb_function_accepts_alpha (and same thing for hsl(H S L / A) https://caniuse.com/mdn-css_types_color_hsl_function_accepts_alpha)

Ayc0 avatar Oct 16 '21 23:10 Ayc0

@Parcly-Taxel @mbostock do you know if this PR is mergeable?

Ayc0 avatar Apr 25 '23 08:04 Ayc0