@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.
Files changed (139) hide show
  1. package/Cargo.toml +23 -8
  2. package/package.json +1 -1
  3. package/src/lib.rs +9 -1
  4. package/src/style.rs +21 -0
  5. package/src/transform_css.rs +530 -0
  6. package/src/utils.rs +370 -0
  7. package/src/visitor.rs +921 -0
  8. package/swc_plugin_styled_jsx.wasm +0 -0
  9. package/tests/errors/nested-style-tags/input.js +31 -0
  10. package/tests/errors/nested-style-tags/output.js +31 -0
  11. package/tests/errors/nested-style-tags/output.stderr +21 -0
  12. package/tests/errors/no-child/input.js +6 -0
  13. package/tests/errors/no-child/output.js +8 -0
  14. package/tests/errors/no-child/output.stderr +7 -0
  15. package/tests/errors/ts-with-css-resolve/input.js +10 -0
  16. package/tests/errors/ts-with-css-resolve/output.js +5 -0
  17. package/tests/errors/ts-with-css-resolve/output.stderr +2 -0
  18. package/tests/errors/two-children/input.js +8 -0
  19. package/tests/errors/two-children/output.js +12 -0
  20. package/tests/errors/two-children/output.stderr +9 -0
  21. package/tests/errors/wrong-child-type/input.js +7 -0
  22. package/tests/errors/wrong-child-type/output.js +10 -0
  23. package/tests/errors/wrong-child-type/output.stderr +8 -0
  24. package/tests/errors/wrong-jsx-expression-type/input.js +7 -0
  25. package/tests/errors/wrong-jsx-expression-type/output.js +10 -0
  26. package/tests/errors/wrong-jsx-expression-type/output.stderr +8 -0
  27. package/tests/fixture/absent/input.js +6 -0
  28. package/tests/fixture/absent/output.js +7 -0
  29. package/tests/fixture/attribute-generation-classname-rewriting/input.js +55 -0
  30. package/tests/fixture/attribute-generation-classname-rewriting/output.js +112 -0
  31. package/tests/fixture/attribute-generation-modes/input.js +166 -0
  32. package/tests/fixture/attribute-generation-modes/output.js +228 -0
  33. package/tests/fixture/class/input.js +14 -0
  34. package/tests/fixture/class/output.js +12 -0
  35. package/tests/fixture/comments/input.js +18 -0
  36. package/tests/fixture/comments/output.js +12 -0
  37. package/tests/fixture/component-attribute/input.js +11 -0
  38. package/tests/fixture/component-attribute/output.js +10 -0
  39. package/tests/fixture/conflicts/input.js +16 -0
  40. package/tests/fixture/conflicts/output.js +14 -0
  41. package/tests/fixture/css-selector-after-pseudo/input.js +18 -0
  42. package/tests/fixture/css-selector-after-pseudo/output.js +11 -0
  43. package/tests/fixture/css-tag-same-file/input.js +25 -0
  44. package/tests/fixture/css-tag-same-file/output.js +21 -0
  45. package/tests/fixture/different-jsx-ids/input.js +23 -0
  46. package/tests/fixture/different-jsx-ids/output.js +24 -0
  47. package/tests/fixture/dynamic-element/input.js +56 -0
  48. package/tests/fixture/dynamic-element/output.js +40 -0
  49. package/tests/fixture/dynamic-element-class/input.js +32 -0
  50. package/tests/fixture/dynamic-element-class/output.js +25 -0
  51. package/tests/fixture/dynamic-element-external/input.js +12 -0
  52. package/tests/fixture/dynamic-element-external/output.js +12 -0
  53. package/tests/fixture/dynamic-this-in-arrow/input.js +41 -0
  54. package/tests/fixture/dynamic-this-in-arrow/output.js +39 -0
  55. package/tests/fixture/exported-jsx-style/input.js +1 -0
  56. package/tests/fixture/exported-jsx-style/output.js +1 -0
  57. package/tests/fixture/exported-non-jsx-style/input.js +1 -0
  58. package/tests/fixture/exported-non-jsx-style/output.js +1 -0
  59. package/tests/fixture/expressions/input.js +90 -0
  60. package/tests/fixture/expressions/output.js +91 -0
  61. package/tests/fixture/external-nested-scope/input.js +5 -0
  62. package/tests/fixture/external-nested-scope/output.js +7 -0
  63. package/tests/fixture/external-stylesheet/input.js +41 -0
  64. package/tests/fixture/external-stylesheet/output.js +34 -0
  65. package/tests/fixture/external-stylesheet-global/input.js +19 -0
  66. package/tests/fixture/external-stylesheet-global/output.js +18 -0
  67. package/tests/fixture/external-stylesheet-multi-line/input.js +9 -0
  68. package/tests/fixture/external-stylesheet-multi-line/output.js +9 -0
  69. package/tests/fixture/fragment/input.js +51 -0
  70. package/tests/fixture/fragment/output.js +47 -0
  71. package/tests/fixture/global/input.js +22 -0
  72. package/tests/fixture/global/output.js +7 -0
  73. package/tests/fixture/global-child-selector/input.js +10 -0
  74. package/tests/fixture/global-child-selector/output.js +8 -0
  75. package/tests/fixture/global-redundant/input.js +12 -0
  76. package/tests/fixture/global-redundant/output.js +10 -0
  77. package/tests/fixture/issue-30480/input.js +7 -0
  78. package/tests/fixture/issue-30480/output.js +15 -0
  79. package/tests/fixture/issue-30570/input.js +15 -0
  80. package/tests/fixture/issue-30570/output.js +12 -0
  81. package/tests/fixture/issue-31562-interpolation-in-mdea/input.js +30 -0
  82. package/tests/fixture/issue-31562-interpolation-in-mdea/output.js +43 -0
  83. package/tests/fixture/mixed-global-scoped/input.js +9 -0
  84. package/tests/fixture/mixed-global-scoped/output.js +11 -0
  85. package/tests/fixture/multiple-jsx/input.js +43 -0
  86. package/tests/fixture/multiple-jsx/output.js +32 -0
  87. package/tests/fixture/nested-style-tags/index.js +0 -0
  88. package/tests/fixture/nested-style-tags/output.js +0 -0
  89. package/tests/fixture/non-styled-jsx-style/input.js +7 -0
  90. package/tests/fixture/non-styled-jsx-style/output.js +12 -0
  91. package/tests/fixture/not-styled-jsx-tagged-templates/input.js +30 -0
  92. package/tests/fixture/not-styled-jsx-tagged-templates/output.js +24 -0
  93. package/tests/fixture/number-after-placeholder/input.js +17 -0
  94. package/tests/fixture/number-after-placeholder/output.js +17 -0
  95. package/tests/fixture/one-off-global-selectors/input.js +10 -0
  96. package/tests/fixture/one-off-global-selectors/output.js +8 -0
  97. package/tests/fixture/source-maps/input.js +8 -0
  98. package/tests/fixture/source-maps/output.js +8 -0
  99. package/tests/fixture/stateless/input.js +8 -0
  100. package/tests/fixture/stateless/output.js +12 -0
  101. package/tests/fixture/styles/input.js +57 -0
  102. package/tests/fixture/styles/output.js +39 -0
  103. package/tests/fixture/styles-external-invalid/input.js +13 -0
  104. package/tests/fixture/styles-external-invalid/output.js +9 -0
  105. package/tests/fixture/styles-external-invalid2/input.js +11 -0
  106. package/tests/fixture/styles-external-invalid2/output.js +8 -0
  107. package/tests/fixture/styles2/input.js +6 -0
  108. package/tests/fixture/styles2/output.js +5 -0
  109. package/tests/fixture/too-many/input.js +35 -0
  110. package/tests/fixture/too-many/output.js +49 -0
  111. package/tests/fixture/tpl-escape-1/input.js +14 -0
  112. package/tests/fixture/tpl-escape-1/output.js +12 -0
  113. package/tests/fixture/tpl-escape-2/input.js +17 -0
  114. package/tests/fixture/tpl-escape-2/output.js +17 -0
  115. package/tests/fixture/tpl-placeholder-1-as-property/input.js +17 -0
  116. package/tests/fixture/tpl-placeholder-1-as-property/output.js +29 -0
  117. package/tests/fixture/tpl-placeholder-2-as-part-of-value/input.js +21 -0
  118. package/tests/fixture/tpl-placeholder-2-as-part-of-value/output.js +34 -0
  119. package/tests/fixture/tpl-placeholder-3-as-value/input.js +17 -0
  120. package/tests/fixture/tpl-placeholder-3-as-value/output.js +28 -0
  121. package/tests/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/input.js +17 -0
  122. package/tests/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/output.js +31 -0
  123. package/tests/fixture/tpl-placeholder-5-values-of-multiple-properties/input.js +16 -0
  124. package/tests/fixture/tpl-placeholder-5-values-of-multiple-properties/output.js +31 -0
  125. package/tests/fixture/transform-css/input.js +176 -0
  126. package/tests/fixture/transform-css/output.js +8 -0
  127. package/tests/fixture/transform-css-complex-selector/input.js +116 -0
  128. package/tests/fixture/transform-css-complex-selector/output.js +8 -0
  129. package/tests/fixture/transform-css-global/input.js +32 -0
  130. package/tests/fixture/transform-css-global/output.js +8 -0
  131. package/tests/fixture/transform-css-media-query/input.js +24 -0
  132. package/tests/fixture/transform-css-media-query/output.js +8 -0
  133. package/tests/fixture/transform-css-normal/input.js +22 -0
  134. package/tests/fixture/transform-css-normal/output.js +8 -0
  135. package/tests/fixture/transform-css-nth-1/input.js +10 -0
  136. package/tests/fixture/transform-css-nth-1/output.js +8 -0
  137. package/tests/fixture/whitespace/input.js +12 -0
  138. package/tests/fixture/whitespace/output.js +12 -0
  139. package/tests/fixture.rs +87 -0
@@ -0,0 +1,228 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import styles from './styles';
3
+ const styles2 = require('./styles2');
4
+ // external only
5
+ export const Test1 = ()=><div className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}>
6
+
7
+ <p className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}>external only</p>
8
+
9
+ <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
10
+
11
+ <_JSXStyle id={styles2.__hash}>{styles2}</_JSXStyle>
12
+
13
+ </div>;
14
+ // external and static
15
+ export const Test2 = ()=><div className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}>
16
+
17
+ <p className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}>external and static</p>
18
+
19
+ <_JSXStyle id={"81a68341e430a972"}>{"p.jsx-81a68341e430a972{color:red}"}</_JSXStyle>
20
+
21
+ <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
22
+
23
+ </div>;
24
+ // external and dynamic
25
+ export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([
26
+ [
27
+ "f08108daf927b99d",
28
+ [
29
+ color
30
+ ]
31
+ ]
32
+ ])}>
33
+
34
+ <p className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([
35
+ [
36
+ "f08108daf927b99d",
37
+ [
38
+ color
39
+ ]
40
+ ]
41
+ ])}>external and dynamic</p>
42
+
43
+ <_JSXStyle id={"f08108daf927b99d"} dynamic={[
44
+ color
45
+ ]}>{`p.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
46
+
47
+ <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
48
+
49
+ </div>;
50
+ // external, static and dynamic
51
+ export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
52
+ [
53
+ "9779eebad83219f8",
54
+ [
55
+ color
56
+ ]
57
+ ]
58
+ ])}>
59
+
60
+ <p className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
61
+ [
62
+ "9779eebad83219f8",
63
+ [
64
+ color
65
+ ]
66
+ ]
67
+ ])}>external, static and dynamic</p>
68
+
69
+ <_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-ceba8c9ce34e3d0c{display:inline-block}"}</_JSXStyle>
70
+
71
+ <_JSXStyle id={"9779eebad83219f8"} dynamic={[
72
+ color
73
+ ]}>{`p.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
74
+
75
+ <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
76
+
77
+ </div>;
78
+ // static only
79
+ export const Test5 = ()=><div className={"jsx-df0159ebd3f9fb6f"}>
80
+
81
+ <p className={"jsx-df0159ebd3f9fb6f"}>static only</p>
82
+
83
+ <_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-df0159ebd3f9fb6f{display:inline-block}"}</_JSXStyle>
84
+
85
+ <_JSXStyle id={"81a68341e430a972"}>{"p.jsx-df0159ebd3f9fb6f{color:red}"}</_JSXStyle>
86
+
87
+ </div>;
88
+ // static and dynamic
89
+ export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
90
+ [
91
+ "9779eebad83219f8",
92
+ [
93
+ color
94
+ ]
95
+ ]
96
+ ])}>
97
+
98
+ <p className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
99
+ [
100
+ "9779eebad83219f8",
101
+ [
102
+ color
103
+ ]
104
+ ]
105
+ ])}>static and dynamic</p>
106
+
107
+ <_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-ceba8c9ce34e3d0c{display:inline-block}"}</_JSXStyle>
108
+
109
+ <_JSXStyle id={"9779eebad83219f8"} dynamic={[
110
+ color
111
+ ]}>{`p.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
112
+
113
+ </div>;
114
+ // dynamic only
115
+ export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([
116
+ [
117
+ "f08108daf927b99d",
118
+ [
119
+ color
120
+ ]
121
+ ]
122
+ ])}>
123
+
124
+ <p className={_JSXStyle.dynamic([
125
+ [
126
+ "f08108daf927b99d",
127
+ [
128
+ color
129
+ ]
130
+ ]
131
+ ])}>dynamic only</p>
132
+
133
+ <_JSXStyle id={"f08108daf927b99d"} dynamic={[
134
+ color
135
+ ]}>{`p.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
136
+
137
+ </div>;
138
+ // dynamic with scoped compound variable
139
+ export const Test8 = ({ color })=>{
140
+ if (color) {
141
+ const innerProps = {
142
+ color
143
+ };
144
+ return <div className={_JSXStyle.dynamic([
145
+ [
146
+ "62256c563b89bfae",
147
+ [
148
+ innerProps.color
149
+ ]
150
+ ]
151
+ ])}>
152
+
153
+ <p className={_JSXStyle.dynamic([
154
+ [
155
+ "62256c563b89bfae",
156
+ [
157
+ innerProps.color
158
+ ]
159
+ ]
160
+ ])}>dynamic with scoped compound variable</p>
161
+
162
+ <_JSXStyle id={"62256c563b89bfae"} dynamic={[
163
+ innerProps.color
164
+ ]}>{`p.__jsx-style-dynamic-selector{color:${innerProps.color}}`}</_JSXStyle>
165
+
166
+ </div>;
167
+ }
168
+ };
169
+ // dynamic with compound variable
170
+ export const Test9 = ({ color })=>{
171
+ const innerProps = {
172
+ color
173
+ };
174
+ return <div className={_JSXStyle.dynamic([
175
+ [
176
+ "708723e452f192e4",
177
+ [
178
+ innerProps.color
179
+ ]
180
+ ]
181
+ ])}>
182
+
183
+ <p className={_JSXStyle.dynamic([
184
+ [
185
+ "708723e452f192e4",
186
+ [
187
+ innerProps.color
188
+ ]
189
+ ]
190
+ ])}>dynamic with compound variable</p>
191
+
192
+ <_JSXStyle id={"708723e452f192e4"} dynamic={[
193
+ innerProps.color
194
+ ]}>{`p.__jsx-style-dynamic-selector{color:${innerProps.color}}`}</_JSXStyle>
195
+
196
+ </div>;
197
+ };
198
+ const foo = 'red';
199
+ // dynamic with constant variable
200
+ export const Test10 = ()=><div className={"jsx-f849b7a02be96503"}>
201
+
202
+ <p className={"jsx-f849b7a02be96503"}>dynamic with constant variable</p>
203
+
204
+ <_JSXStyle id={"f849b7a02be96503"}>{`p.jsx-f849b7a02be96503{color:${foo}}`}</_JSXStyle>
205
+
206
+ </div>;
207
+ // dynamic with complex scope
208
+ export const Test11 = ({ color })=>{
209
+ const items = Array.from({
210
+ length: 5
211
+ }).map((item, i)=><li key={i} className={_JSXStyle.dynamic([
212
+ [
213
+ "a2585dff420632b1",
214
+ [
215
+ color
216
+ ]
217
+ ]
218
+ ]) + " " + "item"}>
219
+
220
+ <_JSXStyle id={"a2585dff420632b1"} dynamic={[
221
+ color
222
+ ]}>{`.item.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
223
+
224
+ Item #{i + 1}
225
+
226
+ </li>);
227
+ return <ul className="items">{items}</ul>;
228
+ };
@@ -0,0 +1,14 @@
1
+ export default class {
2
+ render() {
3
+ return (
4
+ <div>
5
+ <p>test</p>
6
+ <style jsx>{`
7
+ p {
8
+ color: red;
9
+ }
10
+ `}</style>
11
+ </div>
12
+ )
13
+ }
14
+ }
@@ -0,0 +1,12 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ export default class {
3
+ render() {
4
+ return <div className={"jsx-b2b86d63f35d25ee"}>
5
+
6
+ <p className={"jsx-b2b86d63f35d25ee"}>test</p>
7
+
8
+ <_JSXStyle id={"b2b86d63f35d25ee"}>{"p.jsx-b2b86d63f35d25ee{color:red}"}</_JSXStyle>
9
+
10
+ </div>;
11
+ }
12
+ }
@@ -0,0 +1,18 @@
1
+ export default class {
2
+ render() {
3
+ return (
4
+ <div>
5
+ <p>test</p>
6
+ <style jsx>{`
7
+ //
8
+ p {
9
+ //
10
+ color: red;
11
+
12
+ //
13
+ }
14
+ `}</style>
15
+ </div>
16
+ )
17
+ }
18
+ }
@@ -0,0 +1,12 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ export default class {
3
+ render() {
4
+ return <div className={"jsx-1952086b0a5ae64c"}>
5
+
6
+ <p className={"jsx-1952086b0a5ae64c"}>test</p>
7
+
8
+ <_JSXStyle id={"1952086b0a5ae64c"}>{"p.jsx-1952086b0a5ae64c{color:red}"}</_JSXStyle>
9
+
10
+ </div>;
11
+ }
12
+ }
@@ -0,0 +1,11 @@
1
+ const Test = () => (
2
+ <div>
3
+ <span>test</span>
4
+ <Component />
5
+ <style jsx>{`
6
+ span {
7
+ color: red;
8
+ }
9
+ `}</style>
10
+ </div>
11
+ )
@@ -0,0 +1,10 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ const Test = ()=><div className={"jsx-a9535d7d5f32c3c4"}>
3
+
4
+ <span className={"jsx-a9535d7d5f32c3c4"}>test</span>
5
+
6
+ <Component />
7
+
8
+ <_JSXStyle id={"a9535d7d5f32c3c4"}>{"span.jsx-a9535d7d5f32c3c4{color:red}"}</_JSXStyle>
9
+
10
+ </div>;
@@ -0,0 +1,16 @@
1
+
2
+ // TODO
3
+
4
+ // export const _JSXStyle = '_JSXStyle-literal'
5
+ // export default function() {
6
+ // return (
7
+ // <div>
8
+ // <p>test</p>
9
+ // <style jsx>{`
10
+ // p {
11
+ // color: red;
12
+ // }
13
+ // `}</style>
14
+ // </div>
15
+ // )
16
+ // }
@@ -0,0 +1,14 @@
1
+ // TODO
2
+ // export const _JSXStyle = '_JSXStyle-literal'
3
+ // export default function() {
4
+ // return (
5
+ // <div>
6
+ // <p>test</p>
7
+ // <style jsx>{`
8
+ // p {
9
+ // color: red;
10
+ // }
11
+ // `}</style>
12
+ // </div>
13
+ // )
14
+ // }
@@ -0,0 +1,18 @@
1
+ function NavigationItem({
2
+ active,
3
+ className,
4
+ }) {
5
+ return (
6
+ <span className={cn({ active }, className, 'navigation-item')}>
7
+ <style jsx>{`
8
+ .navigation-item :global(a)::after {
9
+ content: attr(data-text);
10
+ content: attr(data-text) / '';
11
+
12
+ }
13
+ `}</style>
14
+ </span>
15
+ );
16
+ }
17
+
18
+ export default NavigationItem;
@@ -0,0 +1,11 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ function NavigationItem({ active , className , }) {
3
+ return <span className={"jsx-2342aae4628612c6" + " " + (cn({
4
+ active
5
+ }, className, 'navigation-item') || "")}>
6
+
7
+ <_JSXStyle id={"2342aae4628612c6"}>{'.navigation-item.jsx-2342aae4628612c6 a::after{content:attr(data-text);content:attr(data-text)/""}'}</_JSXStyle>
8
+
9
+ </span>;
10
+ }
11
+ export default NavigationItem;
@@ -0,0 +1,25 @@
1
+ import css from 'styled-jsx/css'
2
+
3
+ export default ({ children }) => (
4
+ <div>
5
+ <p>{children}</p>
6
+ <style jsx>{styles}</style>
7
+ </div>
8
+ )
9
+
10
+ const styles = css`
11
+ p {
12
+ color: red;
13
+ }
14
+ `
15
+
16
+ class Test extends React.Component {
17
+ render() {
18
+ return (
19
+ <div>
20
+ <p>{this.props.children}</p>
21
+ <style jsx>{styles}</style>
22
+ </div>
23
+ )
24
+ }
25
+ }
@@ -0,0 +1,21 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ export default (({ children })=><div className={`jsx-${styles.__hash}`}>
3
+
4
+ <p className={`jsx-${styles.__hash}`}>{children}</p>
5
+
6
+ <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
7
+
8
+ </div>);
9
+ const styles = new String("p.jsx-556239d258b6d66a{color:red}");
10
+ styles.__hash = "556239d258b6d66a";
11
+ class Test extends React.Component {
12
+ render() {
13
+ return <div className={`jsx-${styles.__hash}`}>
14
+
15
+ <p className={`jsx-${styles.__hash}`}>{this.props.children}</p>
16
+
17
+ <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
18
+
19
+ </div>;
20
+ }
21
+ }
@@ -0,0 +1,23 @@
1
+ const color = 'red'
2
+ const otherColor = 'green'
3
+
4
+ const A = () => (
5
+ <div>
6
+ <p>test</p>
7
+ <style jsx>{`p { color: ${color} }`}</style>
8
+ </div>
9
+ )
10
+
11
+ const B = () => (
12
+ <div>
13
+ <p>test</p>
14
+ <style jsx>{`p { color: ${otherColor} }`}</style>
15
+ </div>
16
+ )
17
+
18
+ export default () => (
19
+ <div>
20
+ <A />
21
+ <B />
22
+ </div>
23
+ )
@@ -0,0 +1,24 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ const color = 'red';
3
+ const otherColor = 'green';
4
+ const A = ()=><div className={"jsx-8522d6f4b7f930d2"}>
5
+
6
+ <p className={"jsx-8522d6f4b7f930d2"}>test</p>
7
+
8
+ <_JSXStyle id={"8522d6f4b7f930d2"}>{`p.jsx-8522d6f4b7f930d2{color:${color}}`}</_JSXStyle>
9
+
10
+ </div>;
11
+ const B = ()=><div className={"jsx-d1ed441bb35f699d"}>
12
+
13
+ <p className={"jsx-d1ed441bb35f699d"}>test</p>
14
+
15
+ <_JSXStyle id={"d1ed441bb35f699d"}>{`p.jsx-d1ed441bb35f699d{color:${otherColor}}`}</_JSXStyle>
16
+
17
+ </div>;
18
+ export default (()=><div >
19
+
20
+ <A />
21
+
22
+ <B />
23
+
24
+ </div>);
@@ -0,0 +1,56 @@
1
+ export default ({ level = 1 }) => {
2
+ const Element = `h${level}`
3
+
4
+ return (
5
+ <Element className="root">
6
+ <p>dynamic element</p>
7
+ <style jsx>{`
8
+ .root {
9
+ background: red;
10
+ }
11
+ `}</style>
12
+ </Element>
13
+ )
14
+ }
15
+
16
+ export const TestLowerCase = ({ level = 1 }) => {
17
+ const element = `h${level}`
18
+
19
+ return (
20
+ <element className="root">
21
+ <p>dynamic element</p>
22
+ <style jsx>{`
23
+ .root {
24
+ background: red;
25
+ }
26
+ `}</style>
27
+ </element>
28
+ )
29
+ }
30
+
31
+ const Element2 = 'div'
32
+ export const Test2 = () => {
33
+ return (
34
+ <Element2 className="root">
35
+ <p>dynamic element</p>
36
+ <style jsx>{`
37
+ .root {
38
+ background: red;
39
+ }
40
+ `}</style>
41
+ </Element2>
42
+ )
43
+ }
44
+
45
+ export const Test3 = ({Component = 'div'}) => {
46
+ return (
47
+ <Component>
48
+ <p>dynamic element</p>
49
+ <style jsx>{`
50
+ .root {
51
+ background: red;
52
+ }
53
+ `}</style>
54
+ </Component>
55
+ );
56
+ }
@@ -0,0 +1,40 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ export default (({ level =1 })=>{
3
+ const Element = `h${level}`;
4
+ return <Element className={"jsx-fca64cc3f069b519" + " " + "root"}>
5
+
6
+ <p className={"jsx-fca64cc3f069b519"}>dynamic element</p>
7
+
8
+ <_JSXStyle id={"fca64cc3f069b519"}>{".root.jsx-fca64cc3f069b519{background:red}"}</_JSXStyle>
9
+
10
+ </Element>;
11
+ });
12
+ export const TestLowerCase = ({ level =1 })=>{
13
+ const element = `h${level}`;
14
+ return <element className={"jsx-fca64cc3f069b519" + " " + "root"}>
15
+
16
+ <p className={"jsx-fca64cc3f069b519"}>dynamic element</p>
17
+
18
+ <_JSXStyle id={"fca64cc3f069b519"}>{".root.jsx-fca64cc3f069b519{background:red}"}</_JSXStyle>
19
+
20
+ </element>;
21
+ };
22
+ const Element2 = 'div';
23
+ export const Test2 = ()=>{
24
+ return <Element2 className="root">
25
+
26
+ <p className={"jsx-fca64cc3f069b519"}>dynamic element</p>
27
+
28
+ <_JSXStyle id={"fca64cc3f069b519"}>{".root.jsx-fca64cc3f069b519{background:red}"}</_JSXStyle>
29
+
30
+ </Element2>;
31
+ };
32
+ export const Test3 = ({ Component ='div' })=>{
33
+ return <Component className={"jsx-f825b24bbab5b83b"}>
34
+
35
+ <p className={"jsx-f825b24bbab5b83b"}>dynamic element</p>
36
+
37
+ <_JSXStyle id={"f825b24bbab5b83b"}>{".root.jsx-f825b24bbab5b83b{background:red}"}</_JSXStyle>
38
+
39
+ </Component>;
40
+ };
@@ -0,0 +1,32 @@
1
+ export default class {
2
+ render() {
3
+ const Element = 'div'
4
+
5
+ return (
6
+ <Element className="root">
7
+ <p>dynamic element</p>
8
+ <style jsx>{`
9
+ .root {
10
+ background: red;
11
+ }
12
+ `}</style>
13
+ </Element>
14
+ )
15
+ }
16
+ }
17
+
18
+ const Element2 = 'div'
19
+ export const Test2 = class {
20
+ render() {
21
+ return (
22
+ <Element2 className="root">
23
+ <p>dynamic element</p>
24
+ <style jsx>{`
25
+ .root {
26
+ background: red;
27
+ }
28
+ `}</style>
29
+ </Element2>
30
+ )
31
+ }
32
+ }
@@ -0,0 +1,25 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ export default class {
3
+ render() {
4
+ const Element = 'div';
5
+ return <Element className={"jsx-f825b24bbab5b83b" + " " + "root"}>
6
+
7
+ <p className={"jsx-f825b24bbab5b83b"}>dynamic element</p>
8
+
9
+ <_JSXStyle id={"f825b24bbab5b83b"}>{".root.jsx-f825b24bbab5b83b{background:red}"}</_JSXStyle>
10
+
11
+ </Element>;
12
+ }
13
+ }
14
+ const Element2 = 'div';
15
+ export const Test2 = class {
16
+ render() {
17
+ return <Element2 className="root">
18
+
19
+ <p className={"jsx-f825b24bbab5b83b"}>dynamic element</p>
20
+
21
+ <_JSXStyle id={"f825b24bbab5b83b"}>{".root.jsx-f825b24bbab5b83b{background:red}"}</_JSXStyle>
22
+
23
+ </Element2>;
24
+ }
25
+ };
@@ -0,0 +1,12 @@
1
+ import styles from './styles2'
2
+
3
+ export default ({ level = 1 }) => {
4
+ const Element = `h${level}`
5
+
6
+ return (
7
+ <Element className="root">
8
+ <p>dynamic element</p>
9
+ <style jsx>{styles}</style>
10
+ </Element>
11
+ )
12
+ }
@@ -0,0 +1,12 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import styles from './styles2';
3
+ export default (({ level =1 })=>{
4
+ const Element = `h${level}`;
5
+ return <Element className={`jsx-${styles.__hash}` + " " + "root"}>
6
+
7
+ <p className={`jsx-${styles.__hash}`}>dynamic element</p>
8
+
9
+ <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
10
+
11
+ </Element>;
12
+ });