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] Add support for CSS variables present in remote @import urls #63

Closed
2 tasks done
phoenisx opened this issue Aug 28, 2022 · 9 comments · Fixed by #70
Closed
2 tasks done

[Feature] Add support for CSS variables present in remote @import urls #63

phoenisx opened this issue Aug 28, 2022 · 9 comments · Fixed by #70
Assignees
Labels
critical Issues that needs to be resolved asap enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@phoenisx
Copy link
Contributor

phoenisx commented Aug 28, 2022

@import can support a lot of types of CSS functions, and when used with url function, it can also be used to fetch CSS from remote URLs. E.g.

@import 'https://www.somewebsite.com/variables.css'

Ref:


TODO

  • Support remote URLs
  • When using postcss plugins like postcss-import, we can also import from node_modules.
@phoenisx phoenisx self-assigned this Aug 28, 2022
@phoenisx phoenisx added this to the 2.2.1 milestone Aug 28, 2022
@phoenisx phoenisx added enhancement New feature or request good first issue Good for newcomers critical Issues that needs to be resolved asap labels Aug 28, 2022
@phoenisx
Copy link
Contributor Author

Parsing CSS in node_modules is still possible using extension settings, but parsing remote CSS files isn't possible yet.

@jjenzz
Copy link

jjenzz commented Sep 2, 2022

Parsing CSS in node_modules is still possible using extension settings

@phoenisx curious how to do this?

i am trying to use open props with this extension and the only way i could figure out how to recognise the files was by removing node_modules from cssvar.ignore which gave me a lot of duplicated variables.

is there a more efficient way?

p.s. i love what you're doing here. it has motivated me to write normal css again (instead of css-in-js) for the first time in yeeears!

@phoenisx
Copy link
Contributor Author

phoenisx commented Sep 3, 2022

Thanks for your kind words and support @jjenzz, and also for bringing this issue to my notice.

To summarize your statement above, you are saying the extension works, but there are too many duplicates, am I correct?

I have a working example for open-props, here: https://github.com/willofindie/vscode-cssvar/tree/main/examples/css-in-node-modules and while testing even I found duplicate declarations that shouldn't have been there.

Let me fix this by today, and I was also thinking to add a config that when enabled, will dedupe all duplicate declarations parsed from all source files, keeping just their location references to navigate to the definition.

@phoenisx
Copy link
Contributor Author

phoenisx commented Sep 3, 2022

Adding more context here, for visibility:

  • The custom properties provided by open-props actually have duplicates in them

image

  • I tried a quick fix locally, to hide duplicates in a single file, and it works, but I am not sure if it is the right way to move forward with, reasons:
    • Single CSS file can have duplicate custom properties, but have different values, like properties defined in @media queries or duplicate props to support theming.
    • Keeping the above in mind, I am thinking to:
      • Create a separate issue for the same
      • Take some time to find a good solution that does not break current support for variables used for theming.

@jjenzz
Copy link

jjenzz commented Sep 3, 2022

I have a working example for open-props, here

thanks for that! not sure why i hadn't looked there before 🙈 sorry.

i have tried the following configuration today which doesn't have any duplicates but i only get colours in my inteilisense (not sizes etc):

{
  "cssvar.themes": ["dark"],
  "cssvar.disableSort": true,
  "cssvar.ignore": ["**/build"],
  "cssvar.files": ["app/**/*.css", "node_modules/open-props/open-props.min.css"],
  "cssvar.excludeThemedVariables": true,
}

intellisense:

CleanShot 2022-09-03 at 19 24 43

i am using pnpm if that helps at all. would you like me to raise a GH issue for this or is there something i am missing?

@phoenisx
Copy link
Contributor Author

phoenisx commented Sep 3, 2022

Hi @jjenzz
I tested your configurations on my system, and couldn't replicate the issue.

out.mp4

Can you try disabling all installed extensions and enabling just this one to validate if some other extension is not causing any conflict?

image image


If the issue still persists, please do raise an issue with the following details:

  • OS and VSCode details
  • Extension and open-props version
  • Also provide if there are any error logs in the devtools console. Details on how to look for console logs provided here

@jjenzz
Copy link

jjenzz commented Sep 4, 2022

i figured out what it was. i had seen in another GH issue that adding the following to extensions.json would help reduce variable duplication but it was actually causing variables to go missing entirely for me:

"[css]": {
  "editor.suggest.showVariables": false
},

removing this configuration fixes it :)

thanks for all your time on this, if there is any way i can send a donation of support please do let me know. i'd love to help you to continue maintaining the extension.

@phoenisx
Copy link
Contributor Author

phoenisx commented Sep 4, 2022

@jjenzz great to hear that you solved the issue.
I pinned this issue today, to track conflicts with default VSCode settings.
The setting that you mentioned above used to work in VSCode prior to v1.71 or v1.70, not sure exactly which one.


thanks for all your time on this, if there is any way i can send a donation of support please do let me know. i'd love to help you to continue maintaining the extension.

I appreciate your support 🙏🏽 🙇🏽 🙌🏽.
I've never given a thought to this, so not sure how exactly it works. I read some blogs about Github Sponsors and would be linking my Sponsors account to this project, once it's approved. DONE 🙌

@jjenzz
Copy link

jjenzz commented Sep 5, 2022

@phoenisx you can add a .github/funding.yml file with your username from your funding provider of choice and it will display a "sponsor this project" link on the repo. details here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical Issues that needs to be resolved asap enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants