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

Language server doesn't handle css.resolve #58

Open
smoores-dev opened this issue Apr 2, 2021 · 5 comments
Open

Language server doesn't handle css.resolve #58

smoores-dev opened this issue Apr 2, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@smoores-dev
Copy link

Hello! I see that a previous issue (#16) called out a bug when a component uses css.global; I'm seeing what seems to be the same issue when using css.resolve:

image

Steps To Reproduce

  1. Add a tagged template using css.resolve

The current behavior

Syntax highlighting and language server responses (autocomplete options) are incorrect/partially missing

The expected behavior

css.resolve-tagged templates behave the same as <styled jsx> tags and css.global-tagged-templates!

@smoores-dev smoores-dev added the bug Something isn't working label Apr 2, 2021
@theoludwig
Copy link
Owner

Thanks for your report! @smores
I don't know if it should be the case, but for your burgerStyles to work you need to wrap it under a className like so :

import css from 'styled-jsx/css'

const burgerStyles = css.resolve`
  .some-class-name {
    display: block;
    position: absolute;
    top: 2.5rem;
    right: 2rem;
  }

  @media (min-width: 769px) {
    .some-class-name {
      display: none;
    }
  }
`

@smoores-dev
Copy link
Author

smoores-dev commented Apr 3, 2021

Interesting! I wonder if this is a quirk of how css.resolve works: it does allow styles at the top level (without a tag)... but now that I'm looking more closely at the docs, this isn't actually a documented feature. This works just fine as is; here's a screenshot of my browser where these styles seem to have been applied correctly:

image

But you're right that the docs suggest nesting these styles in a tag... I personally think that kind of stinks/breaks encapsulation, but I suppose it's fair that your extension doesn't support it given that it isn't documented!

I just opened a thread on the styled-jsx discussion forum asking for clarification: vercel/vercel#6065.

@eliasthompson
Copy link

Related to the topic but not related to the issue of wrapping resolved styles in a className: In our code base we're destructuring the resolve import from styled-jsx/css (import { resolve } from 'styled-jsx/css';), which results in us declaring:

resolve`
   ...
`

This doesn't trigger the syntax highlighting as it specifically looks for css.resolve. Are there any plans to support this either by default or as a configurable option?

(If you feel this should be a separate issue just lmk.)

@theoludwig
Copy link
Owner

Right, I think it is cleaner to use css.resolve, but yes feel free to open a PR with a configurable option to make it work with resolve only. @eliasthompson

@smoores-dev
Copy link
Author

I never ended up getting any responses to that discussion thread.. just tried another tack and opened an issue on styled-jsx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants