@swc/plugin-styled-jsx 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +23 -8
- package/package.json +1 -1
- package/src/lib.rs +9 -1
- package/src/style.rs +21 -0
- package/src/transform_css.rs +530 -0
- package/src/utils.rs +370 -0
- package/src/visitor.rs +921 -0
- package/swc_plugin_styled_jsx.wasm +0 -0
- package/tests/errors/nested-style-tags/input.js +31 -0
- package/tests/errors/nested-style-tags/output.js +31 -0
- package/tests/errors/nested-style-tags/output.stderr +21 -0
- package/tests/errors/no-child/input.js +6 -0
- package/tests/errors/no-child/output.js +8 -0
- package/tests/errors/no-child/output.stderr +7 -0
- package/tests/errors/ts-with-css-resolve/input.js +10 -0
- package/tests/errors/ts-with-css-resolve/output.js +5 -0
- package/tests/errors/ts-with-css-resolve/output.stderr +2 -0
- package/tests/errors/two-children/input.js +8 -0
- package/tests/errors/two-children/output.js +12 -0
- package/tests/errors/two-children/output.stderr +9 -0
- package/tests/errors/wrong-child-type/input.js +7 -0
- package/tests/errors/wrong-child-type/output.js +10 -0
- package/tests/errors/wrong-child-type/output.stderr +8 -0
- package/tests/errors/wrong-jsx-expression-type/input.js +7 -0
- package/tests/errors/wrong-jsx-expression-type/output.js +10 -0
- package/tests/errors/wrong-jsx-expression-type/output.stderr +8 -0
- package/tests/fixture/absent/input.js +6 -0
- package/tests/fixture/absent/output.js +7 -0
- package/tests/fixture/attribute-generation-classname-rewriting/input.js +55 -0
- package/tests/fixture/attribute-generation-classname-rewriting/output.js +112 -0
- package/tests/fixture/attribute-generation-modes/input.js +166 -0
- package/tests/fixture/attribute-generation-modes/output.js +228 -0
- package/tests/fixture/class/input.js +14 -0
- package/tests/fixture/class/output.js +12 -0
- package/tests/fixture/comments/input.js +18 -0
- package/tests/fixture/comments/output.js +12 -0
- package/tests/fixture/component-attribute/input.js +11 -0
- package/tests/fixture/component-attribute/output.js +10 -0
- package/tests/fixture/conflicts/input.js +16 -0
- package/tests/fixture/conflicts/output.js +14 -0
- package/tests/fixture/css-selector-after-pseudo/input.js +18 -0
- package/tests/fixture/css-selector-after-pseudo/output.js +11 -0
- package/tests/fixture/css-tag-same-file/input.js +25 -0
- package/tests/fixture/css-tag-same-file/output.js +21 -0
- package/tests/fixture/different-jsx-ids/input.js +23 -0
- package/tests/fixture/different-jsx-ids/output.js +24 -0
- package/tests/fixture/dynamic-element/input.js +56 -0
- package/tests/fixture/dynamic-element/output.js +40 -0
- package/tests/fixture/dynamic-element-class/input.js +32 -0
- package/tests/fixture/dynamic-element-class/output.js +25 -0
- package/tests/fixture/dynamic-element-external/input.js +12 -0
- package/tests/fixture/dynamic-element-external/output.js +12 -0
- package/tests/fixture/dynamic-this-in-arrow/input.js +41 -0
- package/tests/fixture/dynamic-this-in-arrow/output.js +39 -0
- package/tests/fixture/exported-jsx-style/input.js +1 -0
- package/tests/fixture/exported-jsx-style/output.js +1 -0
- package/tests/fixture/exported-non-jsx-style/input.js +1 -0
- package/tests/fixture/exported-non-jsx-style/output.js +1 -0
- package/tests/fixture/expressions/input.js +90 -0
- package/tests/fixture/expressions/output.js +91 -0
- package/tests/fixture/external-nested-scope/input.js +5 -0
- package/tests/fixture/external-nested-scope/output.js +7 -0
- package/tests/fixture/external-stylesheet/input.js +41 -0
- package/tests/fixture/external-stylesheet/output.js +34 -0
- package/tests/fixture/external-stylesheet-global/input.js +19 -0
- package/tests/fixture/external-stylesheet-global/output.js +18 -0
- package/tests/fixture/external-stylesheet-multi-line/input.js +9 -0
- package/tests/fixture/external-stylesheet-multi-line/output.js +9 -0
- package/tests/fixture/fragment/input.js +51 -0
- package/tests/fixture/fragment/output.js +47 -0
- package/tests/fixture/global/input.js +22 -0
- package/tests/fixture/global/output.js +7 -0
- package/tests/fixture/global-child-selector/input.js +10 -0
- package/tests/fixture/global-child-selector/output.js +8 -0
- package/tests/fixture/global-redundant/input.js +12 -0
- package/tests/fixture/global-redundant/output.js +10 -0
- package/tests/fixture/issue-30480/input.js +7 -0
- package/tests/fixture/issue-30480/output.js +15 -0
- package/tests/fixture/issue-30570/input.js +15 -0
- package/tests/fixture/issue-30570/output.js +12 -0
- package/tests/fixture/issue-31562-interpolation-in-mdea/input.js +30 -0
- package/tests/fixture/issue-31562-interpolation-in-mdea/output.js +43 -0
- package/tests/fixture/mixed-global-scoped/input.js +9 -0
- package/tests/fixture/mixed-global-scoped/output.js +11 -0
- package/tests/fixture/multiple-jsx/input.js +43 -0
- package/tests/fixture/multiple-jsx/output.js +32 -0
- package/tests/fixture/nested-style-tags/index.js +0 -0
- package/tests/fixture/nested-style-tags/output.js +0 -0
- package/tests/fixture/non-styled-jsx-style/input.js +7 -0
- package/tests/fixture/non-styled-jsx-style/output.js +12 -0
- package/tests/fixture/not-styled-jsx-tagged-templates/input.js +30 -0
- package/tests/fixture/not-styled-jsx-tagged-templates/output.js +24 -0
- package/tests/fixture/number-after-placeholder/input.js +17 -0
- package/tests/fixture/number-after-placeholder/output.js +17 -0
- package/tests/fixture/one-off-global-selectors/input.js +10 -0
- package/tests/fixture/one-off-global-selectors/output.js +8 -0
- package/tests/fixture/source-maps/input.js +8 -0
- package/tests/fixture/source-maps/output.js +8 -0
- package/tests/fixture/stateless/input.js +8 -0
- package/tests/fixture/stateless/output.js +12 -0
- package/tests/fixture/styles/input.js +57 -0
- package/tests/fixture/styles/output.js +39 -0
- package/tests/fixture/styles-external-invalid/input.js +13 -0
- package/tests/fixture/styles-external-invalid/output.js +9 -0
- package/tests/fixture/styles-external-invalid2/input.js +11 -0
- package/tests/fixture/styles-external-invalid2/output.js +8 -0
- package/tests/fixture/styles2/input.js +6 -0
- package/tests/fixture/styles2/output.js +5 -0
- package/tests/fixture/too-many/input.js +35 -0
- package/tests/fixture/too-many/output.js +49 -0
- package/tests/fixture/tpl-escape-1/input.js +14 -0
- package/tests/fixture/tpl-escape-1/output.js +12 -0
- package/tests/fixture/tpl-escape-2/input.js +17 -0
- package/tests/fixture/tpl-escape-2/output.js +17 -0
- package/tests/fixture/tpl-placeholder-1-as-property/input.js +17 -0
- package/tests/fixture/tpl-placeholder-1-as-property/output.js +29 -0
- package/tests/fixture/tpl-placeholder-2-as-part-of-value/input.js +21 -0
- package/tests/fixture/tpl-placeholder-2-as-part-of-value/output.js +34 -0
- package/tests/fixture/tpl-placeholder-3-as-value/input.js +17 -0
- package/tests/fixture/tpl-placeholder-3-as-value/output.js +28 -0
- package/tests/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/input.js +17 -0
- package/tests/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/output.js +31 -0
- package/tests/fixture/tpl-placeholder-5-values-of-multiple-properties/input.js +16 -0
- package/tests/fixture/tpl-placeholder-5-values-of-multiple-properties/output.js +31 -0
- package/tests/fixture/transform-css/input.js +176 -0
- package/tests/fixture/transform-css/output.js +8 -0
- package/tests/fixture/transform-css-complex-selector/input.js +116 -0
- package/tests/fixture/transform-css-complex-selector/output.js +8 -0
- package/tests/fixture/transform-css-global/input.js +32 -0
- package/tests/fixture/transform-css-global/output.js +8 -0
- package/tests/fixture/transform-css-media-query/input.js +24 -0
- package/tests/fixture/transform-css-media-query/output.js +8 -0
- package/tests/fixture/transform-css-normal/input.js +22 -0
- package/tests/fixture/transform-css-normal/output.js +8 -0
- package/tests/fixture/transform-css-nth-1/input.js +10 -0
- package/tests/fixture/transform-css-nth-1/output.js +8 -0
- package/tests/fixture/whitespace/input.js +12 -0
- package/tests/fixture/whitespace/output.js +12 -0
- package/tests/fixture.rs +87 -0
|
Binary file
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const Component = () => (
|
|
2
|
+
<>
|
|
3
|
+
<header>
|
|
4
|
+
<Comp>
|
|
5
|
+
<style jsx>{styles}</style>
|
|
6
|
+
<style jsx global>{``}</style>
|
|
7
|
+
</Comp>
|
|
8
|
+
<p><style jsx>{``}</style></p>
|
|
9
|
+
</header>
|
|
10
|
+
<div>
|
|
11
|
+
<h1>
|
|
12
|
+
Welcome!
|
|
13
|
+
<style jsx>{``}</style>
|
|
14
|
+
</h1>
|
|
15
|
+
<style jsx>{``}</style>
|
|
16
|
+
</div>
|
|
17
|
+
<div>
|
|
18
|
+
<style jsx>{``}</style>
|
|
19
|
+
<h1>
|
|
20
|
+
Hello world!
|
|
21
|
+
<style jsx global>{``}</style>
|
|
22
|
+
</h1>
|
|
23
|
+
</div>
|
|
24
|
+
<div>
|
|
25
|
+
<>
|
|
26
|
+
<style jsx>{styles}</style>
|
|
27
|
+
</>
|
|
28
|
+
<style jsx>{``}</style>
|
|
29
|
+
</div>
|
|
30
|
+
</>
|
|
31
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
const Component = ()=><>
|
|
3
|
+
<header >
|
|
4
|
+
<Comp >
|
|
5
|
+
<_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
|
|
6
|
+
<_JSXStyle id={"b3e1b6a7c9b96113"}>{""}</_JSXStyle>
|
|
7
|
+
</Comp>
|
|
8
|
+
<p className={"jsx-b3e1b6a7c9b96113"}><_JSXStyle id={"b3e1b6a7c9b96113"}>{""}</_JSXStyle></p>
|
|
9
|
+
</header>
|
|
10
|
+
<div className={"jsx-b3e1b6a7c9b96113"}>
|
|
11
|
+
<h1 className={"jsx-b3e1b6a7c9b96113"}>
|
|
12
|
+
Welcome!
|
|
13
|
+
<style jsx>{``}</style>
|
|
14
|
+
</h1>
|
|
15
|
+
<_JSXStyle id={"b3e1b6a7c9b96113"}>{""}</_JSXStyle>
|
|
16
|
+
</div>
|
|
17
|
+
<div className={"jsx-b3e1b6a7c9b96113"}>
|
|
18
|
+
<_JSXStyle id={"b3e1b6a7c9b96113"}>{""}</_JSXStyle>
|
|
19
|
+
<h1 className={"jsx-b3e1b6a7c9b96113"}>
|
|
20
|
+
Hello world!
|
|
21
|
+
<style jsx global>{``}</style>
|
|
22
|
+
</h1>
|
|
23
|
+
</div>
|
|
24
|
+
<div className={"jsx-b3e1b6a7c9b96113"}>
|
|
25
|
+
<>
|
|
26
|
+
<style jsx>{styles}</style>
|
|
27
|
+
</>
|
|
28
|
+
<_JSXStyle id={"b3e1b6a7c9b96113"}>{""}</_JSXStyle>
|
|
29
|
+
</div>
|
|
30
|
+
</>
|
|
31
|
+
;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
x Detected nested styled-jsx tag.
|
|
3
|
+
| Read more: https://nextjs.org/docs/messages/nested-styled-jsx-tags
|
|
4
|
+
,-[input.js:13:9]
|
|
5
|
+
13 | <style jsx>{``}</style>
|
|
6
|
+
: ^^^^^^^^^^^^^^^^^^^^^^^
|
|
7
|
+
`----
|
|
8
|
+
|
|
9
|
+
x Detected nested styled-jsx tag.
|
|
10
|
+
| Read more: https://nextjs.org/docs/messages/nested-styled-jsx-tags
|
|
11
|
+
,-[input.js:21:9]
|
|
12
|
+
21 | <style jsx global>{``}</style>
|
|
13
|
+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
14
|
+
`----
|
|
15
|
+
|
|
16
|
+
x Detected nested styled-jsx tag.
|
|
17
|
+
| Read more: https://nextjs.org/docs/messages/nested-styled-jsx-tags
|
|
18
|
+
,-[input.js:26:9]
|
|
19
|
+
26 | <style jsx>{styles}</style>
|
|
20
|
+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
21
|
+
`----
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
const Element = 'div'
|
|
3
|
+
return (
|
|
4
|
+
<div>
|
|
5
|
+
<div className="test" {...test.test} />
|
|
6
|
+
<div className="test" {...test.test.test} />
|
|
7
|
+
<div className="test" {...this.test.test} />
|
|
8
|
+
<div data-test="test" />
|
|
9
|
+
<div className={'test'} />
|
|
10
|
+
<div className={`test`} />
|
|
11
|
+
<div className={`test${true ? ' test2' : ''}`} />
|
|
12
|
+
<div className={'test ' + test} />
|
|
13
|
+
<div className={['test', 'test2'].join(' ')} />
|
|
14
|
+
<div className={true && 'test'} />
|
|
15
|
+
<div className={test ? 'test' : null} />
|
|
16
|
+
<div className={test} />
|
|
17
|
+
<div className={test && 'test'} />
|
|
18
|
+
<div className={test && test('test')} />
|
|
19
|
+
<div className={undefined} />
|
|
20
|
+
<div className={null} />
|
|
21
|
+
<div className={false} />
|
|
22
|
+
<div className={'test'} data-test />
|
|
23
|
+
<div data-test className={'test'} />
|
|
24
|
+
<div className={'test'} data-test="test" />
|
|
25
|
+
<div className={'test'} {...props} />
|
|
26
|
+
<div className={'test'} {...props} {...rest} />
|
|
27
|
+
<div className={`test ${test ? 'test' : ''}`} {...props} />
|
|
28
|
+
<div className={test && test('test')} {...props} />
|
|
29
|
+
<div className={test && test('test') && 'test'} {...props} />
|
|
30
|
+
<div className={test && test('test') && test2('test')} {...props} />
|
|
31
|
+
<div {...props} className={'test'} />
|
|
32
|
+
<div {...props} {...rest} className={'test'} />
|
|
33
|
+
<div {...props} className={'test'} {...rest} />
|
|
34
|
+
<div {...props} />
|
|
35
|
+
<div {...props} {...rest} />
|
|
36
|
+
<div {...props} data-foo {...rest} />
|
|
37
|
+
<div {...props} className={'test'} data-foo {...rest} />
|
|
38
|
+
<div {...{ id: 'foo' }} />
|
|
39
|
+
<div {...{ className: 'foo' }} />
|
|
40
|
+
<div {...{ className: 'foo' }} className="test" />
|
|
41
|
+
<div className="test" {...{ className: 'foo' }} />
|
|
42
|
+
<div {...{ className: 'foo' }} {...bar} />
|
|
43
|
+
<div {...{ className: 'foo' }} {...bar} className="test" />
|
|
44
|
+
<div className="test" {...{ className: 'foo' }} {...bar} />
|
|
45
|
+
<div className="test" {...{ className: props.className }} />
|
|
46
|
+
<div className="test" {...{ className: props.className }} {...bar} />
|
|
47
|
+
<div className="test" {...bar} {...{ className: props.className }} />
|
|
48
|
+
<div className="test" {...bar()} />
|
|
49
|
+
<Element />
|
|
50
|
+
<Element className="test" />
|
|
51
|
+
<Element {...props} />
|
|
52
|
+
<style jsx>{'div { color: red }'}</style>
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=>{
|
|
3
|
+
const Element = 'div';
|
|
4
|
+
return <div className={"jsx-abb4c2202db1a207"}>
|
|
5
|
+
|
|
6
|
+
<div {...test.test} className={"jsx-abb4c2202db1a207" + " " + (test.test && test.test.className != null && test.test.className || "test")}/>
|
|
7
|
+
|
|
8
|
+
<div {...test.test.test} className={"jsx-abb4c2202db1a207" + " " + (test.test.test && test.test.test.className != null && test.test.test.className || "test")}/>
|
|
9
|
+
|
|
10
|
+
<div {...this.test.test} className={"jsx-abb4c2202db1a207" + " " + (this.test.test && this.test.test.className != null && this.test.test.className || "test")}/>
|
|
11
|
+
|
|
12
|
+
<div data-test="test" className={"jsx-abb4c2202db1a207"}/>
|
|
13
|
+
|
|
14
|
+
<div className={"jsx-abb4c2202db1a207" + " " + 'test'}/>
|
|
15
|
+
|
|
16
|
+
<div className={"jsx-abb4c2202db1a207" + " " + `test`}/>
|
|
17
|
+
|
|
18
|
+
<div className={"jsx-abb4c2202db1a207" + " " + `test${true ? ' test2' : ''}`}/>
|
|
19
|
+
|
|
20
|
+
<div className={"jsx-abb4c2202db1a207" + " " + ('test ' + test || "")}/>
|
|
21
|
+
|
|
22
|
+
<div className={"jsx-abb4c2202db1a207" + " " + ([
|
|
23
|
+
'test',
|
|
24
|
+
'test2'
|
|
25
|
+
].join(' ') || "")}/>
|
|
26
|
+
|
|
27
|
+
<div className={"jsx-abb4c2202db1a207" + " " + (true && 'test' || "")}/>
|
|
28
|
+
|
|
29
|
+
<div className={"jsx-abb4c2202db1a207" + " " + ((test ? 'test' : null) || "")}/>
|
|
30
|
+
|
|
31
|
+
<div className={"jsx-abb4c2202db1a207" + " " + (test || "")}/>
|
|
32
|
+
|
|
33
|
+
<div className={"jsx-abb4c2202db1a207" + " " + (test && 'test' || "")}/>
|
|
34
|
+
|
|
35
|
+
<div className={"jsx-abb4c2202db1a207" + " " + (test && test('test') || "")}/>
|
|
36
|
+
|
|
37
|
+
<div className={"jsx-abb4c2202db1a207" + " " + (undefined || "")}/>
|
|
38
|
+
|
|
39
|
+
<div className={"jsx-abb4c2202db1a207" + " " + (null || "")}/>
|
|
40
|
+
|
|
41
|
+
<div className={"jsx-abb4c2202db1a207" + " " + (false || "")}/>
|
|
42
|
+
|
|
43
|
+
<div data-test className={"jsx-abb4c2202db1a207" + " " + 'test'}/>
|
|
44
|
+
|
|
45
|
+
<div data-test className={"jsx-abb4c2202db1a207" + " " + 'test'}/>
|
|
46
|
+
|
|
47
|
+
<div data-test="test" className={"jsx-abb4c2202db1a207" + " " + 'test'}/>
|
|
48
|
+
|
|
49
|
+
<div {...props} className={"jsx-abb4c2202db1a207" + " " + (props && props.className != null && props.className || 'test')}/>
|
|
50
|
+
|
|
51
|
+
<div {...props} {...rest} className={"jsx-abb4c2202db1a207" + " " + (rest && rest.className != null && rest.className || props && props.className != null && props.className || 'test')}/>
|
|
52
|
+
|
|
53
|
+
<div {...props} className={"jsx-abb4c2202db1a207" + " " + (props && props.className != null && props.className || `test ${test ? 'test' : ''}`)}/>
|
|
54
|
+
|
|
55
|
+
<div {...props} className={"jsx-abb4c2202db1a207" + " " + (props && props.className != null && props.className || test && test('test') || "")}/>
|
|
56
|
+
|
|
57
|
+
<div {...props} className={"jsx-abb4c2202db1a207" + " " + (props && props.className != null && props.className || test && test('test') && 'test' || "")}/>
|
|
58
|
+
|
|
59
|
+
<div {...props} className={"jsx-abb4c2202db1a207" + " " + (props && props.className != null && props.className || test && test('test') && test2('test') || "")}/>
|
|
60
|
+
|
|
61
|
+
<div {...props} className={"jsx-abb4c2202db1a207" + " " + 'test'}/>
|
|
62
|
+
|
|
63
|
+
<div {...props} {...rest} className={"jsx-abb4c2202db1a207" + " " + 'test'}/>
|
|
64
|
+
|
|
65
|
+
<div {...props} {...rest} className={"jsx-abb4c2202db1a207" + " " + (rest && rest.className != null && rest.className || 'test')}/>
|
|
66
|
+
|
|
67
|
+
<div {...props} className={"jsx-abb4c2202db1a207" + " " + (props && props.className != null && props.className || "")}/>
|
|
68
|
+
|
|
69
|
+
<div {...props} {...rest} className={"jsx-abb4c2202db1a207" + " " + (rest && rest.className != null && rest.className || props && props.className != null && props.className || "")}/>
|
|
70
|
+
|
|
71
|
+
<div {...props} data-foo {...rest} className={"jsx-abb4c2202db1a207" + " " + (rest && rest.className != null && rest.className || props && props.className != null && props.className || "")}/>
|
|
72
|
+
|
|
73
|
+
<div {...props} data-foo {...rest} className={"jsx-abb4c2202db1a207" + " " + (rest && rest.className != null && rest.className || 'test')}/>
|
|
74
|
+
|
|
75
|
+
<div {...{
|
|
76
|
+
id: 'foo'
|
|
77
|
+
}} className={"jsx-abb4c2202db1a207"}/>
|
|
78
|
+
|
|
79
|
+
<div className={"jsx-abb4c2202db1a207" + " " + 'foo'}/>
|
|
80
|
+
|
|
81
|
+
<div {...{
|
|
82
|
+
className: 'foo'
|
|
83
|
+
}} className={"jsx-abb4c2202db1a207" + " " + "test"}/>
|
|
84
|
+
|
|
85
|
+
<div className="test" className={"jsx-abb4c2202db1a207" + " " + 'foo'}/>
|
|
86
|
+
|
|
87
|
+
<div {...bar} className={"jsx-abb4c2202db1a207" + " " + (bar && bar.className != null && bar.className || 'foo')}/>
|
|
88
|
+
|
|
89
|
+
<div {...{
|
|
90
|
+
className: 'foo'
|
|
91
|
+
}} {...bar} className={"jsx-abb4c2202db1a207" + " " + "test"}/>
|
|
92
|
+
|
|
93
|
+
<div className="test" {...bar} className={"jsx-abb4c2202db1a207" + " " + (bar && bar.className != null && bar.className || 'foo')}/>
|
|
94
|
+
|
|
95
|
+
<div className="test" className={"jsx-abb4c2202db1a207" + " " + (props.className || "")}/>
|
|
96
|
+
|
|
97
|
+
<div className="test" {...bar} className={"jsx-abb4c2202db1a207" + " " + (bar && bar.className != null && bar.className || props.className || "")}/>
|
|
98
|
+
|
|
99
|
+
<div className="test" {...bar} className={"jsx-abb4c2202db1a207" + " " + (props.className || "")}/>
|
|
100
|
+
|
|
101
|
+
<div {...bar()} className={"jsx-abb4c2202db1a207" + " " + "test"}/>
|
|
102
|
+
|
|
103
|
+
<Element className={"jsx-abb4c2202db1a207"}/>
|
|
104
|
+
|
|
105
|
+
<Element className={"jsx-abb4c2202db1a207" + " " + "test"}/>
|
|
106
|
+
|
|
107
|
+
<Element {...props} className={"jsx-abb4c2202db1a207" + " " + (props && props.className != null && props.className || "")}/>
|
|
108
|
+
|
|
109
|
+
<_JSXStyle id={"abb4c2202db1a207"}>{"div.jsx-abb4c2202db1a207{color:red}"}</_JSXStyle>
|
|
110
|
+
|
|
111
|
+
</div>;
|
|
112
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import styles from './styles'
|
|
2
|
+
|
|
3
|
+
const styles2 = require('./styles2')
|
|
4
|
+
|
|
5
|
+
// external only
|
|
6
|
+
export const Test1 = () => (
|
|
7
|
+
<div>
|
|
8
|
+
<p>external only</p>
|
|
9
|
+
<style jsx>{styles}</style>
|
|
10
|
+
<style jsx>{styles2}</style>
|
|
11
|
+
</div>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
// external and static
|
|
15
|
+
export const Test2 = () => (
|
|
16
|
+
<div>
|
|
17
|
+
<p>external and static</p>
|
|
18
|
+
<style jsx>{`
|
|
19
|
+
p {
|
|
20
|
+
color: red;
|
|
21
|
+
}
|
|
22
|
+
`}</style>
|
|
23
|
+
<style jsx>{styles}</style>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
// external and dynamic
|
|
28
|
+
export const Test3 = ({ color }) => (
|
|
29
|
+
<div>
|
|
30
|
+
<p>external and dynamic</p>
|
|
31
|
+
<style jsx>{`
|
|
32
|
+
p {
|
|
33
|
+
color: ${color};
|
|
34
|
+
}
|
|
35
|
+
`}</style>
|
|
36
|
+
<style jsx>{styles}</style>
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
// external, static and dynamic
|
|
41
|
+
export const Test4 = ({ color }) => (
|
|
42
|
+
<div>
|
|
43
|
+
<p>external, static and dynamic</p>
|
|
44
|
+
<style jsx>{`
|
|
45
|
+
p {
|
|
46
|
+
display: inline-block;
|
|
47
|
+
}
|
|
48
|
+
`}</style>
|
|
49
|
+
<style jsx>{`
|
|
50
|
+
p {
|
|
51
|
+
color: ${color};
|
|
52
|
+
}
|
|
53
|
+
`}</style>
|
|
54
|
+
<style jsx>{styles}</style>
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
// static only
|
|
59
|
+
export const Test5 = () => (
|
|
60
|
+
<div>
|
|
61
|
+
<p>static only</p>
|
|
62
|
+
<style jsx>{`
|
|
63
|
+
p {
|
|
64
|
+
display: inline-block;
|
|
65
|
+
}
|
|
66
|
+
`}</style>
|
|
67
|
+
<style jsx>{`
|
|
68
|
+
p {
|
|
69
|
+
color: red;
|
|
70
|
+
}
|
|
71
|
+
`}</style>
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
// static and dynamic
|
|
76
|
+
export const Test6 = ({ color }) => (
|
|
77
|
+
<div>
|
|
78
|
+
<p>static and dynamic</p>
|
|
79
|
+
<style jsx>{`
|
|
80
|
+
p {
|
|
81
|
+
display: inline-block;
|
|
82
|
+
}
|
|
83
|
+
`}</style>
|
|
84
|
+
<style jsx>{`
|
|
85
|
+
p {
|
|
86
|
+
color: ${color};
|
|
87
|
+
}
|
|
88
|
+
`}</style>
|
|
89
|
+
</div>
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
// dynamic only
|
|
93
|
+
export const Test7 = ({ color }) => (
|
|
94
|
+
<div>
|
|
95
|
+
<p>dynamic only</p>
|
|
96
|
+
<style jsx>{`
|
|
97
|
+
p {
|
|
98
|
+
color: ${color};
|
|
99
|
+
}
|
|
100
|
+
`}</style>
|
|
101
|
+
</div>
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
// dynamic with scoped compound variable
|
|
105
|
+
export const Test8 = ({ color }) => {
|
|
106
|
+
if (color) {
|
|
107
|
+
const innerProps = { color }
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<div>
|
|
111
|
+
<p>dynamic with scoped compound variable</p>
|
|
112
|
+
<style jsx>{`
|
|
113
|
+
p {
|
|
114
|
+
color: ${innerProps.color};
|
|
115
|
+
}
|
|
116
|
+
`}</style>
|
|
117
|
+
</div>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// dynamic with compound variable
|
|
123
|
+
export const Test9 = ({ color }) => {
|
|
124
|
+
const innerProps = { color }
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div>
|
|
128
|
+
<p>dynamic with compound variable</p>
|
|
129
|
+
<style jsx>{`
|
|
130
|
+
p {
|
|
131
|
+
color: ${innerProps.color};
|
|
132
|
+
}
|
|
133
|
+
`}</style>
|
|
134
|
+
</div>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const foo = 'red'
|
|
139
|
+
|
|
140
|
+
// dynamic with constant variable
|
|
141
|
+
export const Test10 = () => (
|
|
142
|
+
<div>
|
|
143
|
+
<p>dynamic with constant variable</p>
|
|
144
|
+
<style jsx>{`
|
|
145
|
+
p {
|
|
146
|
+
color: ${foo};
|
|
147
|
+
}
|
|
148
|
+
`}</style>
|
|
149
|
+
</div>
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
// dynamic with complex scope
|
|
153
|
+
export const Test11 = ({ color }) => {
|
|
154
|
+
const items = Array.from({ length: 5 }).map((item, i) => (
|
|
155
|
+
<li className="item" key={i}>
|
|
156
|
+
<style jsx>{`
|
|
157
|
+
.item {
|
|
158
|
+
color: ${color};
|
|
159
|
+
}
|
|
160
|
+
`}</style>
|
|
161
|
+
Item #{i + 1}
|
|
162
|
+
</li>
|
|
163
|
+
))
|
|
164
|
+
|
|
165
|
+
return <ul className="items">{items}</ul>
|
|
166
|
+
}
|