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

hovering / color decoration support for custom patterns #247

Closed
jamessouth opened this issue Sep 2, 2021 · 10 comments
Closed

hovering / color decoration support for custom patterns #247

jamessouth opened this issue Sep 2, 2021 · 10 comments
Labels
contribution welcome has workaround p2-low this is not breaking anything but nice to have it addressed

Comments

@jamessouth
Copy link

Hello, there doesn't seem to be a way to customize class name contexts like in TW. Here is the TW issue. Intellisense works with className=.... but not with className: .... etc. Could such support be added?

Thank you!

@alexanderniebuhr
Copy link
Member

You can configure that with custom regex pattern I guess.

@alexanderniebuhr
Copy link
Member

for that className: .... i think it would something like this

"windicss.includeLanguages": {
    "<filetype_identifier>": {
        "type":"html",
        "patterns": [
            (\\s*class(Name)?\\s*\\:\\s*{?\\s*[\"'`])[^\"'`]*$
        ]
    }
},

@jamessouth
Copy link
Author

well I tried several regexes, including what worked for me with TW, for js/jsreact and couldn't get it to recognize className: ...., but thank you for your help.

@alexanderniebuhr
Copy link
Member

If you can show me an example code, I could look into it for you.

@jamessouth
Copy link
Author

JS like this, React without JSX, also similar to the JS ReScript compiles to:

//App.js
const ce = React.createElement;
export default function App() {
  return ce(
        "div",
        {
          className: "mt-8",
        }
  );
}

Hovering over the 'mt-8' does nothing unless I replace the ': ' with an equal sign. So in settings I tried:

"windicss.includeLanguages": {
    "<filetype_identifier>": {
        "type":"html",
        "patterns": [
            "(\\s*class(Name)?\\s*\\:\\s*{?\\s*[\"'`])[^\"'`]*$"
        ]
    }
}

with javascript and javascriptreact for filetype_identifier, html and js for type, and your suggested regex plus "(\\s*class(Name)?\\s*\\:\\s*{?\\s*[\"'`])[^\"'`]*\"" and "className:\\s*\"([^\"]*)\"" for patterns. I reloaded the window each time but never got it to show the CSS class definition on hover.

@alexanderniebuhr
Copy link
Member

@jamessouth, so does autocomplete of classes works?
I think includeLanguages has only support for autocomplete for now, color boxes and hovering had to be added in another PR. :/

@alexanderniebuhr alexanderniebuhr added the pending triage Not classified yet label Sep 4, 2021
@alexanderniebuhr alexanderniebuhr changed the title Add support for custom classname contexts hovering / color decoration support for custom patterns Sep 4, 2021
@alexanderniebuhr alexanderniebuhr added contribution welcome has workaround p2-low this is not breaking anything but nice to have it addressed and removed pending triage Not classified yet labels Sep 4, 2021
@alexanderniebuhr
Copy link
Member

@jamessouth
Copy link
Author

Yes, thank you, with this on 21.4

    "windicss.includeLanguages": {
        "rescript": "html",
        "javascript": {
            "type":"js",
            "patterns": [
                "(\\s*class(Name)?\\s*\\:\\s*{?\\s*[\"'`])[^\"'`]*$"
            ]
        }
    }

the JS hovering and class completion work, but I am not getting color boxes in JS once I select a class from the drop-down menu. I do get color boxes in rescript files though.

@alexanderniebuhr
Copy link
Member

yeah that is something i have to include in a later release

@jamessouth
Copy link
Author

Ok. Thank you for all your help Alexander!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome has workaround p2-low this is not breaking anything but nice to have it addressed
Projects
None yet
Development

No branches or pull requests

2 participants