Skip to content

Commit 3376c69

Browse files
authored
Merge pull request #134 from dev-five-git/conditional-pattern
Add conditional pattern
2 parents c0c43f6 + 98c7b47 commit 3376c69

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

.changeset/plenty-months-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/react": patch
3+
---
4+
5+
Add support conditional pattern

libs/extractor/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,19 @@ mod tests {
844844
"test.tsx",
845845
r#"import { Box } from "@devup-ui/core";
846846
<Box margin={a ?? "1px"} />;
847+
"#,
848+
ExtractOption {
849+
package: "@devup-ui/core".to_string(),
850+
css_file: None
851+
}
852+
)
853+
.unwrap());
854+
855+
reset_class_map();
856+
assert_debug_snapshot!(extract(
857+
"test.tsx",
858+
r#"import { Box } from "@devup-ui/core";
859+
<Box margin={(a===1||a===2)&&b===3 && "1px"} />;
847860
"#,
848861
ExtractOption {
849862
package: "@devup-ui/core".to_string(),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "extract(\"test.tsx\",\nr#\"import { Box } from \"@devup-ui/core\";\n<Box margin={(a===1||a===2)&&b===3 && \"1px\"} />;\n\"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap()"
4+
---
5+
ExtractOutput {
6+
styles: [
7+
Static(
8+
ExtractStaticStyle {
9+
property: "margin",
10+
value: "1px",
11+
level: 0,
12+
selector: None,
13+
style_order: None,
14+
},
15+
),
16+
],
17+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className={(a === 1 || a === 2) && b === 3 ? \"d0\" : \"\"} />;\n",
18+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type Value<T> = T | null | undefined
1+
type Value<T> = T | null | undefined | false
22
export type ResponsiveValue<T> = 0 extends T
33
? Value<number | T> | Value<number | T>[]
44
: Value<T> | Value<T>[]

0 commit comments

Comments
 (0)