Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-kiwis-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devup-ui/wasm": patch
---

Fix dark selector issue
57 changes: 29 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions libs/extractor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ version = "0.1.0"
edition = "2021"

[dependencies]
oxc_parser = "0.50.0"
oxc_syntax = "0.50.0"
oxc_span = "0.50.0"
oxc_allocator = "0.50.0"
oxc_ast = "0.50.0"
oxc_codegen = "0.50.0"
oxc_parser = "0.51.0"
oxc_syntax = "0.51.0"
oxc_span = "0.51.0"
oxc_allocator = "0.51.0"
oxc_ast = "0.51.0"
oxc_codegen = "0.51.0"
css = { path = "../css" }
once_cell = "1.20.3"

Expand Down
21 changes: 21 additions & 0 deletions libs/extractor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,27 @@ import {Button} from '@devup/ui'
}
)
.unwrap());
println!("=================");

reset_class_map();
assert_debug_snapshot!(extract(
"test.js",
r#"import {Box} from '@devup-ui/core'
<Box _hover={{bg:"white"}} _themeDark={{
selectors: {
'& :is(svg,img)': {
boxSize: '100%',
filter: 'brightness(0) invert(1)',
},
},
}} />
"#,
ExtractOption {
package: "@devup-ui/core".to_string(),
css_file: None
}
)
.unwrap());
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
source: libs/extractor/src/lib.rs
expression: "extract(\"test.js\",\nr#\"import {Box} from '@devup-ui/core'\n <Box _hover={{bg:\"white\"}} _themeDark={{\n selectors: {\n '& :is(svg,img)': {\n boxSize: '100%',\n filter: 'brightness(0) invert(1)',\n },\n },\n }} />\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap()"
---
ExtractOutput {
styles: [
Static(
ExtractStaticStyle {
property: "background",
value: "white",
level: 0,
selector: Some(
Selector(
"&:hover",
),
),
style_order: None,
},
),
Static(
ExtractStaticStyle {
property: "boxSize",
value: "100%",
level: 0,
selector: Some(
Selector(
":root[data-theme=dark] & :is(svg,img)",
),
),
style_order: None,
},
),
Static(
ExtractStaticStyle {
property: "filter",
value: "brightness(0) invert(1)",
level: 0,
selector: Some(
Selector(
":root[data-theme=dark] & :is(svg,img)",
),
),
style_order: None,
},
),
],
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"d0 d1 d2\" />;\n",
}
14 changes: 13 additions & 1 deletion libs/extractor/src/style_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,19 @@
None,
&mut o.value,
level,
Some(&name.as_str().into()),
Some(
&if let Some(selector) = selector {
format!(
"{}{}",

Check warning on line 275 in libs/extractor/src/style_extractor.rs

View check run for this annotation

Codecov / codecov/patch

libs/extractor/src/style_extractor.rs#L275

Added line #L275 was not covered by tests
selector.to_string().split("&").collect::<Vec<_>>()[0],
name.as_str()
)
} else {
name
}
.as_str()
.into(),

Check warning on line 283 in libs/extractor/src/style_extractor.rs

View check run for this annotation

Codecov / codecov/patch

libs/extractor/src/style_extractor.rs#L282-L283

Added lines #L282 - L283 were not covered by tests
),
) {
props.append(&mut styles);
}
Expand Down