pucelle / vscode-css-navigation

Allowing Go to definition from HTML to CSS, or Find References from CSS to HTML.
https://marketplace.visualstudio.com/items?itemName=pucelle.vscode-css-navigation
MIT License
64 stars 8 forks source link

Support for React className #1

Closed mmcmm closed 5 years ago

mmcmm commented 5 years ago

Hello, nice extension,

I installed it but it doesn't have any support (go to, completion) for react className, other than this looks good.

Thanks

pucelle commented 5 years ago

Thanks for your feedback, I will work on it in one or two days.

pucelle commented 5 years ago

Hi, mmcmm, I'm not a React user, can you provide some representative code pieces so I can add them to my test cases? Thanks.

mmcmm commented 5 years ago

Well in react when you set a class you need use className instead, nothing is different, just instead of class is className. Here it is the same thing in css peek https://github.com/pranaygp/vscode-css-peek/issues/3

render() { return <span className="menu navigation-menu">Menu</span> }

pucelle commented 5 years ago

https://github.com/pucelle/vscode-css-navigation/commit/13753d7755c189203ee6f25ca765ed8269355d9a This commit should fixed this.

Here is my test case: https://github.com/pucelle/vscode-css-navigation/commit/13753d7755c189203ee6f25ca765ed8269355d9a#diff-90f1f2b5e8f51bd56248f8d82ec15cec

pucelle commented 5 years ago

Sorry I'm new to GitHub, I'm trying to reference code pieces to show them here... And failed.

pucelle commented 5 years ago

OK, This time it should work. Here is my test case, please check if it can cover your scenarios. https://github.com/pucelle/vscode-css-navigation/blob/13753d7755c189203ee6f25ca765ed8269355d9a/client/test/fixture/index.jsx#L1-L7

craigcosmo commented 5 years ago

it does not work

import './home.scss'
class Home extends React.Component {
    render() {
        return (
                <div className="homeComponent">
                    <div className="menuwrapper" />
                </div>
        )
    }
}
.homeComponent {
    .menuwrapper {
    }
}

click go to definition won't go anywhere

pucelle commented 5 years ago

Hi, craigcosmo , can you provide you work directory info: What's your work space folder, and the file paths of your jsx and css file. Thanks.

pucelle commented 5 years ago

Otherwise to know what's happening, you can click Ctrl + Shift + U to open Output tab, then choose CSS Navigation, analysis the console logs, or just paste them here.

craigcosmo commented 5 years ago

I delete the extension and install again. its working now. Thanks for making this.