microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.48k stars 28.64k forks source link

[css] Add new CSS color functions #165207

Open ai opened 1 year ago

ai commented 1 year ago

Снимок экрана от 2022-11-02 00-55-30

CSS Color Modules 4 added many new color functions. This spec already Candidate Recommendation Draft and was implemented in Safari 15 without any flags. We already have a few articles about the most interesting of them oklch() and lch().

We need the same color preview box as we have for other colors like red.

Functions:

aeschli commented 1 year ago

Help is welcome. Implementation would be in https://github.com/microsoft/vscode-css-languageservice

WaqasAliAbbasi commented 1 year ago

https://github.com/microsoft/vscode-css-languageservice/blob/main/src/languageFacts/colors.ts#L409 seems like a place to start around. I can take a look at it over the next week if that's okay with you?

GauravB159 commented 1 year ago

I'd love to help out with this, or even assist on a smaller part of it if someone more experienced picks it up.

Update:

I've got the conversion functions for LAB to RGB up, I'm still trying to figure out how to connect it to the editor since any changes aren't being reflected it seems. Is there an issue created in https://github.com/microsoft/vscode-css-languageservice that I could possibly send a pull request to once I am done?

@aeschli

Update 2:

I've got the autofill for LAB working, but I still cannot figure out the color picker logic. I can see that it's in this file src\vs\editor\contrib\colorPicker\browser\colorDetector.ts but I do not understand how to get it to detect the lab() function from the CSS file. I can see a ColorProvider coming from an extension, but I do not understand how I might add a new color format for the CSS ColorProvider.

Any help would be appreciated, thanks.

Update 3:

I have got it working as a preview as well, not sure if that is all the work that is needed, or do we need to add this function to the color picker code as well? That might be a bit too complex for me.

@ai

image

Update 4:

So another issue - lab() takes possible negative values in the second and third argument. Since no other color function does this, the parser apparently has not handled this case. So the code does not work for negative values. I've figured out the change I need to make but I'm not sure if this will affect something else. Certain unit tests are failing so I'm probably breaking something with this, looking for a better fix.

image

Update 5:

All tests are passing with this logic

image

ryanleichty commented 11 months ago

Was just looking for a solution to preview oklch() colors. @GauravB159 Your PR looks promising! Is it stalled currently?

DutchEllie commented 8 months ago

Hey guys, please pick this up again? I love these functions, but everlacking support for new things makes them hard to work with. I always thought browser implementations were slow, but I should've expected this...

Richard-L commented 7 months ago

+1 to have this. Would be so fantastic 🙏

GauravB159 commented 7 months ago

@ryanleichty I'm not sure, I haven't looked at this in a while but I don't think I received a response on my PR for it. I can have a look again to make sure it's working.

Edit: My PR was in draft, I've put it up for review now but I think there was still some stuff to do to complete it from the comments I see on it

jrmoynihan commented 7 months ago

Thanks for submitting the PR @GauravB159 ! This is going to be a great addition when it passes all the tests!

AShortcuts commented 4 months ago

Please keep up the great work. Thank you for what you've done so far

sashareds commented 3 months ago

Thanks for submitting the PR @GauravB159 ! This is going to be a great addition when it passes all the tests!

Any update on that? oklch/lch still don't have previews @jrmoynihan image

jrmoynihan commented 3 months ago

Thanks for submitting the PR @GauravB159 ! This is going to be a great addition when it passes all the tests!

Any update on that? oklch/lch still don't have previews @jrmoynihan image

I'm not a maintainer or the author of the PR, so nothing from me. Looks like it still isn't merged. Maybe more review to do?

robzor commented 1 month ago

+1 for the implementation of this into VSCode, I'm using oklch on a new project after reading the excellent evil martians article

Sofahamster commented 1 month ago

Almost two years and we're still lacking support for oklch. What can be done to get this integrated?

Richard-L commented 1 month ago

+1 for the implementation of this into VSCode, I'm using oklch on a new project after reading the excellent evil martians article

This article is indeed fantastic and excites you about CSS colour capabilities. Really hope VSCode can add support for oklch, or at least an extension might surface.