Add support for styled-jsx / CSS in JS syntax #860
+33
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch adds support for CSS in JS libraries like styled-jsx with partial support for others like styled-components (in particular the "css backtick" syntax only).
This plugin had basic intellisense support for the
<style jsx>
syntax, but lacked support for the css / css.resolve / css.global backtick syntax that is used by styled-jsx. Furthermore, because of the way<style jsx>
blocks function syntactically (they are actually JS strings, not CSS blocks), this plugin's package.json incorrectly specifies the grammar scopes necessary to trigger the syntax highlighting rules on the style blocks. This PR fixes both of these issues that affect compatibility with styled-jsx and the like.Below is a before/after screenshot pair of how this feature works alongside embedded CSS using both the css backtick syntax as well as the
<style jsx>
tags with both highlighting and intellisense functioning as expected. Note that this feature still depends on the user installing blanu.vscode-styled-jsx (or the styled-components variant) to provide the actual base CSS syntax highlighting for those styled blocks. If you do test this, please make sure you've installed that plugin.Before
After
Since I'm a first time contributor, I'm unsure what, if any, tests might be needed, but do let me know if I should add any.