GithubHelp home page GithubHelp logo

Comments (10)

ticktockreed avatar ticktockreed commented on June 8, 2024 1

Thanks for looking into this! We have a work around for now, but would certainly be interested if you make any progress on this.

from vscode-css-variables.

phoenisx avatar phoenisx commented on June 8, 2024

How do u intend to use css variables in JS and TS??

from vscode-css-variables.

ticktockreed avatar ticktockreed commented on June 8, 2024

We're using EmotionJS in some projects and Aphrodite in others. So would need access within .js or .ts files.

See example below:

// aphrodite example - moduleStyle.js 

import { StyleSheet } from 'aphrodite/no-important';
export default StyleSheet.create({
  title: {
    color: var(--dp_text)
  },
});

// emotionJS example -  module.style.ts

const primaryButton = (theme: TLTheme) => css`
  background-color: var(--dp_button_primary_background);
  color: var(--dp_text_inverted);
  :hover {
    background-color: var(--dp_button_primary_background_hover);
  }

  :active {
    background-color: var(--dp_button_primary_background_pressed);
  }
`;

from vscode-css-variables.

phoenisx avatar phoenisx commented on June 8, 2024

I understand your concern!

I am building my own extension to support CSS Variables and CSS Module IntelliSense which you can find HERE. It's still in the alpha stage. It works great with plain CSS and other CSS language extensions like SCSS etc.

I tried your scenario in my extension, it works but with a hack. I see VSCode API fails to trigger autocomplete if JS file is opened. I mean, unless a CSS file is opened once the Autocomplete doesn't trigger at all.

Check the below illustration, the IntelliSense triggers but only after you open a CSS or SCSS or a similar file.
issue

I will add this to my TODO list. I was thinking this would be a simple task, but it looks like it needs re-thinking for my extension and also needs re-architecting my whole extension.

You can open an issue (if u want to) HERE

from vscode-css-variables.

phoenisx avatar phoenisx commented on June 8, 2024

js

I hope this is what you were looking for. I fixed it in my extension 😅 🎉
Thanks for making me aware of this feature 👍🏾

from vscode-css-variables.

vunguyentuan avatar vunguyentuan commented on June 8, 2024

Thanks for the plugin, works great for CSS and preprocessor CSS.

It would be great to have access to CSS vars via autocomplete within .js and .ts files.

How feasible is this?

Yes it is feasible but it will very annoying to other people because they dont want to get css suggestion on their ts, or js files.

I will try to allow users to decide that files they want to get autocomplete :)

from vscode-css-variables.

vunguyentuan avatar vunguyentuan commented on June 8, 2024

@ticktockreed this should work now, thanks for the feedback.
The new version now supports goto definition and simplifies config or no config.

screencast 2021-12-22 12-39-21

from vscode-css-variables.

karlhorky avatar karlhorky commented on June 8, 2024

@vunguyentuan would you consider allowing disabling this feature for projects that do not use CSS-in-JS?

For example, adding a new setting called cssVariables.autocompleteInLanguages, default values below:

{
  "cssVariables.autocompleteInLanguages": [
    "css",
    "less",
    "scss",
    "postcss",
    "javascript",
    "javascriptreact",
    "typescriptreact"
  ],
}

Or, if this is based on file extension instead of language in the file, a new setting called cssVariables.autocompleteInFiles, default values:

{
  "cssVariables.autocompleteInFiles": [
    "*.css",
    "*.scss",
    "*.sass",
    "*.less",
    "*.js",
    "*.jsx",
    "*.ts",
    "*.tsx"
  ]
}

Otherwise, the extension fills the autocomplete entries all over the place in JS, JSX, TS and TSX files with useless entries for CSS variables:

Screenshot 2023-01-24 at 11 40 59

from vscode-css-variables.

karlhorky avatar karlhorky commented on June 8, 2024

I can also create a new issue if you would prefer.

from vscode-css-variables.

karlhorky avatar karlhorky commented on June 8, 2024

Opened #58 to track this.

from vscode-css-variables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.