Skip to content

Commit 602ea03

Browse files
committed
Add testcase
1 parent 737f501 commit 602ea03

22 files changed

Lines changed: 900 additions & 0 deletions

libs/extractor/src/lib.rs

Lines changed: 464 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import stylex from '@stylexjs/stylex';\nconst key = 'base';\nconst styles = stylex.create({ [key]: { color: 'red' } });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {},
7+
code: "import stylex from \"@stylexjs/stylex\";\nconst key = \"base\";\nconst styles = {};\n",
8+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import stylex from '@stylexjs/stylex';\nconst styles = stylex.create({ base: { fontSize: 16, lineHeight: 1.5 } });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "font-size",
10+
value: "16",
11+
level: 0,
12+
selector: None,
13+
style_order: None,
14+
layer: None,
15+
},
16+
),
17+
Static(
18+
ExtractStaticStyle {
19+
property: "line-height",
20+
value: "1.5",
21+
level: 0,
22+
selector: None,
23+
style_order: None,
24+
layer: None,
25+
},
26+
),
27+
},
28+
code: "import \"@devup-ui/react/devup-ui.css\";\nimport stylex from \"@stylexjs/stylex\";\nconst styles = { \"base\": \"a b\" };\n",
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import stylex from '@stylexjs/stylex';\nconst styles = stylex.create({ base: (x) => { return { color: x }; } });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {},
7+
code: "import stylex from \"@stylexjs/stylex\";\nconst styles = { \"base\": \"\" };\n",
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import stylex from '@stylexjs/stylex';\nconst styles = stylex.create({ base: () => ({ color: 'red' }) });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {},
7+
code: "import stylex from \"@stylexjs/stylex\";\nconst styles = { \"base\": \"\" };\n",
8+
}
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: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import stylex from '@stylexjs/stylex';\nconst fadeIn = stylex.keyframes({ from: { opacity: '0' }, to: { opacity: '1' } });\nconst styles = stylex.create({ base: (dur) => ({ animationName: fadeIn, animationDuration: dur }) });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "animation-name",
10+
value: "a",
11+
level: 0,
12+
selector: None,
13+
style_order: None,
14+
layer: None,
15+
},
16+
),
17+
Dynamic(
18+
ExtractDynamicStyle {
19+
property: "animation-duration",
20+
level: 0,
21+
identifier: "dur",
22+
selector: None,
23+
style_order: None,
24+
},
25+
),
26+
Keyframes(
27+
ExtractKeyframes {
28+
keyframes: {
29+
"from": [
30+
ExtractStaticStyle {
31+
property: "opacity",
32+
value: "0",
33+
level: 0,
34+
selector: None,
35+
style_order: None,
36+
layer: None,
37+
},
38+
],
39+
"to": [
40+
ExtractStaticStyle {
41+
property: "opacity",
42+
value: "1",
43+
level: 0,
44+
selector: None,
45+
style_order: None,
46+
layer: None,
47+
},
48+
],
49+
},
50+
},
51+
),
52+
},
53+
code: "import \"@devup-ui/react/devup-ui.css\";\nimport stylex from \"@stylexjs/stylex\";\nconst fadeIn = \"a\";\nconst styles = { \"base\": \"c d\" };\n",
54+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import stylex from '@stylexjs/stylex';\nconst styles = stylex.create({ base: (x) => ({ fontSize: 16, height: x }) });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "font-size",
10+
value: "16",
11+
level: 0,
12+
selector: None,
13+
style_order: None,
14+
layer: None,
15+
},
16+
),
17+
Dynamic(
18+
ExtractDynamicStyle {
19+
property: "height",
20+
level: 0,
21+
identifier: "x",
22+
selector: None,
23+
style_order: None,
24+
},
25+
),
26+
},
27+
code: "import \"@devup-ui/react/devup-ui.css\";\nimport stylex from \"@stylexjs/stylex\";\nconst styles = { \"base\": \"b c\" };\n",
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import stylex from '@stylexjs/stylex';\nconst styles = stylex.create({ base: { zIndex: stylex.firstThatWorks(10, 20) } });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "z-index",
10+
value: "10",
11+
level: 0,
12+
selector: None,
13+
style_order: None,
14+
layer: None,
15+
},
16+
),
17+
Static(
18+
ExtractStaticStyle {
19+
property: "z-index",
20+
value: "20",
21+
level: 0,
22+
selector: None,
23+
style_order: None,
24+
layer: None,
25+
},
26+
),
27+
},
28+
code: "import \"@devup-ui/react/devup-ui.css\";\nimport stylex from \"@stylexjs/stylex\";\nconst styles = { \"base\": \"a b\" };\n",
29+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import { create, unknownFunction } from '@stylexjs/stylex';\nconst styles = create({ base: { color: 'red' } });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "color",
10+
value: "red",
11+
level: 0,
12+
selector: None,
13+
style_order: None,
14+
layer: None,
15+
},
16+
),
17+
},
18+
code: "import \"@devup-ui/react/devup-ui.css\";\nimport { create, unknownFunction } from \"@stylexjs/stylex\";\nconst styles = { \"base\": \"a\" };\n",
19+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import stylex from '@stylexjs/stylex';\nconst base = stylex.create({ dynamic: (x) => ({ color: x, fontSize: '14px' }) });\nconst composed = stylex.create({ fancy: { ...stylex.include(base.dynamic), backgroundColor: 'blue' } });\"#,\nExtractOption\n{\n package: \"@devup-ui/react\".to_string(), css_dir:\n \"@devup-ui/react\".to_string(), single_css: true, import_main_css: false,\n import_aliases: HashMap::new()\n},).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "background-color",
10+
value: "blue",
11+
level: 0,
12+
selector: None,
13+
style_order: None,
14+
layer: None,
15+
},
16+
),
17+
Static(
18+
ExtractStaticStyle {
19+
property: "font-size",
20+
value: "14px",
21+
level: 0,
22+
selector: None,
23+
style_order: None,
24+
layer: None,
25+
},
26+
),
27+
Dynamic(
28+
ExtractDynamicStyle {
29+
property: "color",
30+
level: 0,
31+
identifier: "x",
32+
selector: None,
33+
style_order: None,
34+
},
35+
),
36+
},
37+
code: "import \"@devup-ui/react/devup-ui.css\";\nimport stylex from \"@stylexjs/stylex\";\nconst base = { \"dynamic\": \"b c\" };\nconst composed = { \"fancy\": \"b c d\" };\n",
38+
}

0 commit comments

Comments
 (0)