Re: [community-group] Color first draft (updated) (#266)

> @caoimghgin Thanks for suggesting this! At this point we **are** conforming to CSS Color Module 4, per your suggestion. So everything you’d like to accomplish will work with our current version of the proposed syntax! But at this time we’re not open to considering “just accept any CSS string” since those are famously NOT easy to parse, and it is NOT a simple regex to get the values (they support arbitrary whitespace, numbers and percentages, in many functions are very lax when it comes to commas and other characters, etc.). It’s only trivially parseable if you defined a very limited subset of what CSS allows.
> 
> But the good news is we’ve done that! We have a nearly 1:1 translation of CSS Color Module 4, just in JSON object notation form. No RegEx needed, and static JSON is much friendlier as a universal interface to every programming language. JS may make parsing, data types, and memory assignment easy, but many other languages do not and parsing CSS would be a significant technical barrier and beyond the scope of this format.

Thanks for replying. I have no doubt we are conforming to CSS Color Module 4. Having recently pulled code from https://colorjs.io/ and inserted an isValid function as a PR, I see the challenges of “just accept any Color() CSS string”, but it appears color.js solved to a satisfactory level.  Advantage: No need to create another format using JSON object notation.

I'm not certain I've encountered a case where other languages are unable to RegExp as easily as JS, but I haven't used every language. Indeed, I'm struggling to imagine what language aside from JS would be used.

I suppose the communication is that with JSON object notation format, we've invented another standard and we're placing a lot of responsibility on the JS plugin to parse color data from Figma/Sketch/etc where I suspect that responsibility is better placed in the transformer. 

It may seem difficult to separate what is good practice from personal preference, but happy to have a forum to share. 

-- 
GitHub Notification of comment by caoimghgin
Please view or discuss this issue at https://github.com/design-tokens/community-group/pull/266#issuecomment-2766529269 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 31 March 2025 15:04:32 UTC