Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color completion non hex #166220

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

GauravB159
Copy link
Contributor

Partial fix for #166197 in conjunction with (Add PR ID for CSS Extension here)

The current code cannot parse hwb color function, or native color strings and does not render the color preview in completion. I have added an extra condition that simply takes the fact that the extension determined it was a color and renders it directly. It works for hwb and native colors now as long as the CSS Extension PR is merged.

@aeschli
Copy link
Contributor

aeschli commented Nov 14, 2022

It's risky to take the value provided by an extension and set it to CSS. It could be used to inject custom css into VS Code.
The clean way would be to add a color field to the proposal API.

@GauravB159
Copy link
Contributor Author

GauravB159 commented Nov 14, 2022

@aeschli I figured so. I thought adding a separate type in CompletionItemKind might be a good way, something like NativeColor that is set when one of that list of colors is true, but that too would be set by the extension and would have the same problem as well.

What do you mean by adding a color field to the proposal API? I can look into it

Edit: Do you mean the extension should pass a hash color value always that it used to display the preview? So the extensions themselves are responsible for parsing their color string.

@aeschli
Copy link
Contributor

aeschli commented Nov 15, 2022

What do you mean by adding a color field to the proposal API? I can look into it

This would be new API. I wanted to bring it up for discussion with @jrieken.

@GauravB159
Copy link
Contributor Author

Ah interesting! Let me know if I can help in any way when that comes around then, I suppose.

@romainmenke
Copy link

I don't think it is ideal to assume it is a renderable color when something has completion kind Color.

With custom properties, calc, color-mix and relative color syntax it is easy to write something that is a color, but can not be used to generate a preview.

:root {
  --a: rgb(var(--red-channel) 0 127);
  --b: color-mix(var(--one), var(--two));
  --c: rgb(from var(--a) calc(r / 2) g b);
}

These are all color values and should/could have completion kind Color but these are not suitable to use as values for a preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants