Skip to content

Set CSS rule priority based on media query break points #82

@liamqma

Description

@liamqma

First of all, I just want to say "Awesome work". I have been looking forward to using Stylex since 2021 😃.

Is your feature request related to a problem? Please describe.
I have the below styles.

const styles = stylex.create({
   foo: {
      "@media (min-width: 10px)": {
         color: "red"
      },
      "@media (min-width: 20px)": {
         color: "green"
      }
   }
});

I am expecting

"@media (min-width: 20px)": {
  color: "green"
}

to be placed after

"@media (min-width: 10px)": {
      color: "red"
}

in the sheet.

However, the 👆 code gets babel transformed to

stylex.inject("@media (min-width: 10px){.xl9lbu0.xl9lbu0{color:red}}", 3200);
stylex.inject("@media (min-width: 20px){.xwdmb1y.xwdmb1y{color:green}}", 3200);

These two CSS rules have the same priority, which means the order of these two rules is indeterministic.

Describe a solution you'd like
When we calculate property property, can we consider the breakpoint value from media atrule?

Describe alternatives you've considered
I cannot think of anything alternative.

Additional context
I've raised a similar question in Compiled CSS-in-JS. atlassian-labs/compiled#1567

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions