Skip to content

Commit e899ae5

Browse files
committed
Update snapshot and rules
1 parent b16b3b1 commit e899ae5

File tree

366 files changed

+1313
-344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

366 files changed

+1313
-344
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
source: bindings/devup-ui-wasm/src/lib.rs
3-
expression: get_css(None).unwrap()
3+
expression: "get_css(None, false).unwrap().split(\"*/\").nth(1).unwrap()"
44
---
55
"@layer t;@layer t{:root{color-scheme:light;--primary:light-dark(#FFF,#000)}:root[data-theme=dark]{color-scheme:dark}}"

libs/css/src/style_selector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ impl From<&str> for StyleSelector {
163163
} else if let Some(s) = value.strip_prefix("theme-") {
164164
// first character should lower case
165165
StyleSelector::Selector(format!(":root[data-theme={}] &", to_camel_case(s)))
166-
} else if value == "print" {
166+
} else if matches!(value.as_str(), "print" | "screen" | "speech" | "all") {
167167
StyleSelector::At {
168168
kind: AtRuleKind::Media,
169-
query: "print".to_string(),
169+
query: value.to_string(),
170170
selector: None,
171171
}
172172
} else {

libs/extractor/src/extractor/extract_style_from_expression.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,48 @@ pub fn extract_style_from_expression<'a>(
239239
};
240240
}
241241

242+
// Handle at-rules: @media, @supports, @container (or _media, _supports, _container)
243+
let at_rule_name = name
244+
.strip_prefix("@")
245+
.or_else(|| name.strip_prefix("_"))
246+
.filter(|n| matches!(*n, "media" | "supports" | "container"));
247+
248+
if let Some(at_rule) = at_rule_name
249+
&& let Expression::ObjectExpression(obj) = expression
250+
{
251+
let mut props = vec![];
252+
for p in obj.properties.iter_mut() {
253+
if let ObjectPropertyKind::ObjectProperty(o) = p
254+
&& let Some(query) = get_string_by_property_key(&o.key)
255+
{
256+
let at_selector = StyleSelector::At {
257+
kind: match at_rule {
258+
"media" => css::style_selector::AtRuleKind::Media,
259+
"supports" => css::style_selector::AtRuleKind::Supports,
260+
"container" => css::style_selector::AtRuleKind::Container,
261+
_ => unreachable!(),
262+
},
263+
query: query.to_string(),
264+
selector: selector.as_ref().map(|s| s.to_string()),
265+
};
266+
props.extend(
267+
extract_style_from_expression(
268+
ast_builder,
269+
None,
270+
&mut o.value,
271+
level,
272+
&Some(at_selector),
273+
)
274+
.styles,
275+
);
276+
}
277+
}
278+
return ExtractResult {
279+
styles: props,
280+
..ExtractResult::default()
281+
};
282+
}
283+
242284
if let Some(new_selector) = name.strip_prefix("_") {
243285
return extract_style_from_expression(
244286
ast_builder,

0 commit comments

Comments
 (0)