Skip to content

Commit

Permalink
fix issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
iFwu committed Sep 7, 2018
1 parent 14a9d23 commit f10aad9
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 13 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Change Log
All notable changes to the "vscode-styled-jsx" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]
- Initial release
TODO
4 changes: 2 additions & 2 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
The MIT License (MIT)
Copyright (c) 2017 Graham Clark, Julien Poissonnier, Xiao Fu
Copyright (c) 2018 Graham Clark, Julien Poissonnier, Xiao Fu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

Syntax highlighting for [styled-jsx](https://github.com/zeit/styled-jsx)

<img src="https://raw.githubusercontent.com/xekri/vscode-styled-jsx/master/highlight-preview.jpg" width="400">


Syntaxes files are inspired by [vscode-styled-components](https://github.com/styled-components/vscode-styled-components.git)
Uses the CSS grammar from the Atom [language-babel](https://github.com/gandm/language-babel).

## Plan

* Add support for css attributes autocomplete
* Add support for css attributes autocomplete
* Add support for classNames autocomplete
Binary file removed highlight-preview.jpg
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"name": "vscode-styled-jsx",
"displayName": "vscode-styled-jsx",
"description": "Syntax highlighting for styled-jsx",
"version": "0.2.3",
"version": "0.2.5",
"publisher": "blanu",
"engines": {
"vscode": "^1.5.0"
"vscode": "^1.26.0"
},
"repository": {
"type": "git",
"url": "https://github.com/xekri/vscode-styled-jsx"
},
"categories": [
"Languages"
"Programming Languages"
],
"contributes": {
"languages": [
Expand Down
10 changes: 8 additions & 2 deletions syntaxes/jsx-styled.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@
"patterns": [
{
"contentName": "source.jsx.styled",
"begin": "\\s*+((?<=<style jsx>{)|(?<=<style jsx global>{)|(?<=<style global jsx>{)|css)\\s*(`)",
"begin": "(?:(?:\\s*+((?<=<style jsx>)|(?<=<style jsx global>)|(?<=<style global jsx>))({))|(?:\\s++css))\\s*(`)",
"beginCaptures": {
"1": {
"name": "entity.name.tag.js"
},
"2": {
"name": "punctuation.definition.block.js"
},
"3": {
"name": "punctuation.definition.quasi.begin.js"
}
},
"end": "\\s*(?<=[^\\\\]\\\\\\\\|[^\\\\]|^\\\\\\\\|^)((`))",
"end": "\\s*(?<=[^\\\\]\\\\\\\\|[^\\\\]|^\\\\\\\\|^)(`)(})?",
"endCaptures": {
"2": {
"name": "punctuation.definition.block.js"
},
"1": {
"name": "punctuation.definition.quasi.end.js"
}
Expand Down
14 changes: 14 additions & 0 deletions test/dynamic.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const Button = props => (
<button>
{props.children}
<style jsx>{`
button {
padding: ${"large" in props ? "50" : "20"}px;
background: ${props.theme.background};
color: #999;
display: inline-block;
font-size: 1em;
}
`}</style>
</button>
);
6 changes: 6 additions & 0 deletions test/fixture/highlight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import css from 'styled-jsx/css'

// should be identified as styled jsx style and hightlight
export const button = css`button { color: hotpink; }`
// shouldn't break original syntax highlight
const resources = `partials.scss`
11 changes: 11 additions & 0 deletions test/global.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default () => (
<div>
<style jsx global>{`
body {
color: #999;
display: inline-block;
font-size: 2em;
}
`}</style>
</div>
)
19 changes: 19 additions & 0 deletions test/normal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const Button = (props) => (
<button>
{ props.children }
<style jsx>{`
button {
color: #999;
display: inline-block;
font-size: 2em;
}
`}</style>
<style jsx>{`
button {
padding: ${ 'large' in props ? '50' : '20' }px;
position: relative;
background: ${props.theme.background};
}
`}</style>
</button>
)
5 changes: 5 additions & 0 deletions test/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
color: #999;
display: inline-block;
font-size: 2em;
}

0 comments on commit f10aad9

Please sign in to comment.