facelessuser / ColorHelper

Sublime plugin that provides helpful color previews and tooltips
https://facelessuser.github.io/ColorHelper/
MIT License
254 stars 30 forks source link

Fix some issues related to color() syntax #185

Closed facelessuser closed 3 years ago

facelessuser commented 3 years ago

It recently came to our attention that we were handling the color() syntax incorrectly for lab which is now corrected on master. This related to any color spaces that provided percentage only channels, so it impacted color(hsl) etc. It now seems there is a conversation whether lab should drop the lab() syntax or the color() syntax. I find the CSS design process a bit frustrating as it is often difficult to gauge the goal of some of these syntaxes.

It seemed that color() was meant to generally unify a new color syntax moving forward to create a common serialization method...and yet, even though the authors of the CSS spec implemented a JavaScript library serializing all colors this way, colors with hues were not actually supposed to be serialized this way (the spec is very unclear on this point). Technically color(lch), color(hsl), etc. aren't valid CSS even though they implemented their library to do so. Maybe this is because cylindrical inputs are only meant for users, and when rendering, colors are always done in the non-cylindrical form?

Regardless, we still allow serializing cylindrical colors with color() even if it is just for consistency and our own internal handling. If they ever formally add support for cylindrical spaces and require something different when specifying angles (hues), we may have to update palettes and such to handle it.


So the above is the current state of things, here is what I need to decide.

So, we have a change on 'master' that will update palettes to fix our initial mixup with lab and percent only channels, but now I'm hesitating to push it because they might deprecate the lab() form or maybe the color() form for lab(). There is a current issue discussing just this.

If they deprecate the color() form for lab(), it is no big deal, and we can continue to use it for serialization if we so choose. We do it for lch() which doesn't technically have a color() form, so this would be no different.

If they drop lab(), it technically would mean we just need to remove lab() as an input and output option. It won't affect how things are stored in our palette as we use the common color() serialization method.

If they decide to drop lab() and extend color() to lch() (dropping lch() as well) they may want to formally support hue and extend color() to hsl(), hwb(), etc. Will that mean they will give a hue specific syntax? We just accept a number currently, but if they want something for explicit, such as 130deg, we ould have to change things. If so, we may need to update palettes again. Should we wait until they make a decision and adjust the palette updates in one shot? Or just do it as the need arises?

facelessuser commented 3 years ago

I should clarify, the latest "published" document was unclear about what spaces were formally supported by color(), the latest draft is much more clear. Though the fact that the CSS authors also implemented their library with support for color() and basically any color did add to the confusion.

I am pretty much only looking at the draft these days, so early on, I think I used to reference the published document, and that is where I came away with this confusion.

Regardless, I'm thinking maybe we'll just roll with what we have. There is no way to predict what they will decide and when, and I'd rather get something out that better reflects what is currently implemented. I know Safari's Tech preview implements things as we have it on master now, so maybe we just do that.

facelessuser commented 3 years ago

So, CSS is dropping syntax for color(lab ...). I guess they still aren't sure how/if they would define angles. If color(lab ...) is defined, then color(lch ...) should be as well, but they don't want to spend time defining angles. Will they be added back in the future? Maybe 🤷🏻. Will the syntax be different for angles than what we have now? Maybe 🤷🏻.

I was under the impression that color() was meant to be a common serialization method in the future, but as usual, I'm not sure what they want. I understand lab() is more concise, and they can solve a common serialization method in the future, so maybe we'll see it in the future? Regardless, we will keep it as a common serialization method.