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

[Feature] Code Completion for css variables #75

Open
ascii-husky opened this issue Oct 17, 2019 · 4 comments
Open

[Feature] Code Completion for css variables #75

ascii-husky opened this issue Oct 17, 2019 · 4 comments

Comments

@ascii-husky
Copy link

Hey

Thanks for the plugin!

Would it be possible to add code completion for css variables defined like this?

const GlobalStyle = createGlobalStyle`
  :root {
      --border-width: 7.5vw;
  }
`
@prigara
Copy link
Collaborator

prigara commented Oct 17, 2019

Can you please add a link to the docs explaining how it works with Styled Components (mainly, where this variable should be visible)? I haven't found anything about using CSS variables in the Style Components docs... Thanks!

@ascii-husky
Copy link
Author

I also didn't find anything in the docs. But I can confirm that css variables work with styled components.
You can use it in a component like this border-width: var(--border-width);.
Please see the official spec here: https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties

Using css variables has some advantages against using JS variables in styled components. Having code completion for them would be a nice feature.

@swandir
Copy link

swandir commented Dec 16, 2019

Styled Components do not change the way CSS custom properties work. It's true in general, since it's stated that all standard CSS is supported.

PostCSS specifics do not apply as well, so it's a plain standard CSS feature.

The issue is basically boils down to tracking declared custom properties. Since they are propagated to child elements through CSS inheritance it might be impossible to track them intelligently. Resolving all custom properties declared anywhere in the project (tagged literals, object styles, CSS files) seems most practical.

@undeadcat
Copy link
Contributor

This depends on the IDE bug https://youtrack.jetbrains.com/issue/WEB-38704.

Completion for css variables currently does not work within language injections, which is the generic IDE mechanism this plugin uses to mark parts of code as CSS-like code.

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

No branches or pull requests

4 participants