Skip to content

Commit 1573747

Browse files
authored
Merge branch 'main' into fix/comments-with-quotes
2 parents a3c9ec3 + 8980fd5 commit 1573747

File tree

5 files changed

+316
-213
lines changed

5 files changed

+316
-213
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@typescript-eslint/eslint-plugin": "^6.13.1",
4848
"@typescript-eslint/parser": "^6.13.1",
4949
"commitizen": "^3.0.2",
50-
"esbuild": "0.14.25",
50+
"esbuild": "0.19.10",
5151
"esbuild-register": "3.3.2",
5252
"eslint": "^7.11.0",
5353
"eslint-plugin-unused-imports": "^2.0.0",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`Styled Styles > Styled class is generated properly 1`] = `
4+
{
5+
"output": "
6+
const Div = styled.div\` color: #FFF;
7+
text-align: right;
8+
position: relative;
9+
max-width: 537px;
10+
margin: 1022px 47px 0 0;
11+
font: 300 16px/25px Barlow, -apple-system, Roboto, Helvetica, sans-serif ;
12+
@media (max-width: 991px) { max-width: 100%;
13+
margin: 40px 10px 0 0; }\`;
14+
",
15+
}
16+
`;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { componentToReact } from '@/generators/react';
2+
import { collectStyledComponents } from './collect-styled-components';
3+
4+
describe('Styled Styles', () => {
5+
const mitosisJson = {
6+
'@type': '@builder.io/mitosis/component',
7+
imports: [],
8+
exports: {},
9+
meta: { useMetadata: {} },
10+
refs: {},
11+
state: {},
12+
children: [
13+
{
14+
'@type': '@builder.io/mitosis/node',
15+
name: 'div',
16+
meta: {},
17+
scope: {},
18+
properties: {},
19+
bindings: {
20+
css: {
21+
code: "{color:'#FFF',textAlign:'right',position:'relative',maxWidth:'537px','@media (max-width: 991px)':{maxWidth:'100%',margin:'40px 10px 0 0'},margin:'1022px 47px 0 0',font:'300 16px/25px Barlow, -apple-system, Roboto, Helvetica, sans-serif '}",
22+
},
23+
},
24+
children: [
25+
{
26+
'@type': '@builder.io/mitosis/node',
27+
name: 'div',
28+
meta: {},
29+
scope: {},
30+
properties: {
31+
_text:
32+
"Makeup artist Rosie Johnson's spirit is tightly intertwined with the world of art, fashion and beauty. She specialises in providing hair and makeup services on the Gold Coast, keeping track of all the latest trends and new directions in the industry. She uses professional and high level industry standard techniques to enhance your best features.\r<br/>\r<br/>Hair styling options are flexible to suit your event, preferences and hair, from classic sleek up styles to voluminous curls, or braided boho looks.<br/>\r<br/>Her and the Makeup Palace teams priority is to ensure you feel amazing and take your ideas, individual face shape, skin and hair, to create a look that you love. Based on the Gold Coast, her formal hair and makeup services have inspired confidence and beauty on wedding days, special occasions and more.",
33+
},
34+
bindings: {},
35+
children: [],
36+
},
37+
],
38+
},
39+
],
40+
context: { get: {}, set: {} },
41+
subComponents: [],
42+
name: 'MyBasicNestedComponent',
43+
hooks: { onMount: [], onEvent: [] },
44+
};
45+
46+
test('Styled class is generated properly', () => {
47+
expect({ output: collectStyledComponents(mitosisJson as any) }).toMatchSnapshot();
48+
});
49+
50+
test('Generated React code should not throw exception', () => {
51+
expect(() => {
52+
componentToReact({ stylesType: 'styled-components', plugins: [] })({
53+
component: mitosisJson as any,
54+
});
55+
}).not.toThrowError();
56+
});
57+
});

packages/core/src/helpers/styles/collect-styled-components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const collectStyledComponents = (json: MitosisComponent): string => {
6565
item.name = className;
6666

6767
styledComponentsCode += `
68-
const ${className} = ${prefix}${str}\`
68+
const ${className} = ${prefix}${str}\`;
6969
`;
7070
}
7171
delete item.bindings.css;

0 commit comments

Comments
 (0)