Skip to content

Commit bb22970

Browse files
authored
Merge pull request #32 from dev-five-git/call-issue
Fix call issue
2 parents 5ed42a9 + 539e296 commit bb22970

File tree

6 files changed

+95
-5
lines changed

6 files changed

+95
-5
lines changed

.changeset/neat-emus-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/wasm": patch
3+
---
4+
5+
Fix walk issue, add flex props

libs/extractor/src/extract_style/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct ExtractStaticStyle {
2121
static MAINTAIN_VALUE_PROPERTIES: Lazy<HashSet<String>> = Lazy::new(|| {
2222
let mut set = HashSet::<String>::new();
2323
set.insert("opacity".to_string());
24+
set.insert("flex".to_string());
2425
set.insert("zIndex".to_string());
2526
set.insert("fontWeight".to_string());
2627
set.insert("scale".to_string());

libs/extractor/src/lib.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ export {
956956
assert_debug_snapshot!(extract(
957957
"test.js",
958958
r#"import {Flex} from '@devup-ui/core'
959-
<Flex opacity={1} zIndex={2} fontWeight={900} scale={2} />
959+
<Flex opacity={1} zIndex={2} fontWeight={900} scale={2} flex={1} />
960960
"#,
961961
ExtractOption {
962962
package: "@devup-ui/core".to_string(),
@@ -1116,4 +1116,26 @@ export {
11161116
)
11171117
.unwrap());
11181118
}
1119+
1120+
#[test]
1121+
#[serial]
1122+
fn test_component_in_func() {
1123+
reset_class_map();
1124+
assert_debug_snapshot!(extract(
1125+
"test.js",
1126+
r#"import {Flex} from '@devup-ui/core'
1127+
PROCESS_DATA.map(({ id, title, content }, idx) => (
1128+
<MotionDiv key={idx}>
1129+
<Flex alignItems="center" gap={[3, null, 5, null, 10]}>
1130+
</Flex>
1131+
</MotionDiv>
1132+
))
1133+
"#,
1134+
ExtractOption {
1135+
package: "@devup-ui/core".to_string(),
1136+
css_file: None
1137+
}
1138+
)
1139+
.unwrap());
1140+
}
11191141
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "extract(\"test.js\",\nr#\"import {Flex} from '@devup-ui/core'\nPROCESS_DATA.map(({ id, title, content }, idx) => (\n <MotionDiv key={idx}>\n <Flex alignItems=\"center\" gap={[3, null, 5, null, 10]}>\n </Flex>\n </MotionDiv>\n ))\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap()"
4+
---
5+
ExtractOutput {
6+
styles: [
7+
Static(
8+
ExtractStaticStyle {
9+
property: "display",
10+
value: "flex",
11+
level: 0,
12+
selector: None,
13+
basic: true,
14+
},
15+
),
16+
Static(
17+
ExtractStaticStyle {
18+
property: "alignItems",
19+
value: "center",
20+
level: 0,
21+
selector: None,
22+
basic: false,
23+
},
24+
),
25+
Static(
26+
ExtractStaticStyle {
27+
property: "gap",
28+
value: "12px",
29+
level: 0,
30+
selector: None,
31+
basic: false,
32+
},
33+
),
34+
Static(
35+
ExtractStaticStyle {
36+
property: "gap",
37+
value: "20px",
38+
level: 2,
39+
selector: None,
40+
basic: false,
41+
},
42+
),
43+
Static(
44+
ExtractStaticStyle {
45+
property: "gap",
46+
value: "40px",
47+
level: 4,
48+
selector: None,
49+
basic: false,
50+
},
51+
),
52+
],
53+
code: "import \"@devup-ui/core/devup-ui.css\";\nPROCESS_DATA.map(({ id, title, content }, idx) => <MotionDiv key={idx}>\n <div className=\"d0 d1 d2 d3 d4\">\n </div>\n </MotionDiv>);\n",
54+
}

libs/extractor/src/snapshots/extractor__tests__maintain_value.snap

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: libs/extractor/src/lib.rs
3-
expression: "extract(\"test.js\",\nr#\"import {Flex} from '@devup-ui/core'\n <Flex opacity={1} zIndex={2} fontWeight={900} scale={2} />\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap()"
3+
expression: "extract(\"test.js\",\nr#\"import {Flex} from '@devup-ui/core'\n <Flex opacity={1} zIndex={2} fontWeight={900} scale={2} flex={1} />\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap()"
44
---
55
ExtractOutput {
66
styles: [
@@ -49,6 +49,15 @@ ExtractOutput {
4949
basic: false,
5050
},
5151
),
52+
Static(
53+
ExtractStaticStyle {
54+
property: "flex",
55+
value: "1",
56+
level: 0,
57+
selector: None,
58+
basic: false,
59+
},
60+
),
5261
],
53-
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"d0 d1 d2 d3 d4\" />;\n",
62+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"d0 d1 d2 d3 d4 d5\" />;\n",
5463
}

libs/extractor/src/visit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ impl<'a> VisitMut<'a> for DevupVisitor<'a> {
171171
}
172172
}
173173
}
174-
175-
walk_call_expression(self, it);
176174
}
175+
walk_call_expression(self, it);
177176
}
178177
fn visit_tagged_template_expression(&mut self, it: &mut TaggedTemplateExpression<'a>) {
179178
if let Expression::Identifier(ident) = &it.tag {

0 commit comments

Comments
 (0)