Expand description
Media query transformation functionality.
Implements the βlast media query winsβ transformation logic for CSS-in-JS. This ensures proper specificity handling when multiple media queries target the same properties.
This implementation provides media query transformation:
- DFS traversal of the style object
- At depth >= 1, apply negation-based media query transformation
- Use pure AST manipulation, not range-based logic
FunctionsΒ§
- are_
media_ πqueries_ disjoint - Check if all media queries represent disjoint width/height ranges
- combine_
media_ πquery_ with_ negations - Combine media query with negations - matches JS combineMediaQueryWithNegations exactly
- create_
object_ πfrom_ key_ values - Helper function to create ObjectLit from key-value pairs
- dfs_
process_ πqueries_ with_ depth - DFS traversal with depth tracking - matches JS dfsProcessQueries exactly
- extract_
width_ πheight_ range - Extract width/height range from a media query if itβs a simple range
- key_
value_ πto_ str - Helper function to extract key as string from KeyValueProp
- last_
media_ query_ wins_ transform - Main entry point - equivalent to lastMediaQueryWinsTransform in JS
- last_
media_ query_ wins_ transform_ internal - Internal helper function for backwards compatibility with existing tests
This preserves the old Vec
-> Vec signature for internal use - normalize_
media_ πquery_ syntax - Just normalize media query syntax without applying negation logic
- ranges_
overlap π - Check if two ranges overlap
- transform_
media_ πqueries_ in_ result - Transform media queries in the result object - matches JS logic exactly