Closed liamqma closed 11 months ago
@JakeLane @dddlr @itsdouges @zerosicx
I realised that this approach only works if stylesheet extraction is enabled, as it needs to sort the entire sheet at once.
When stylesheet extraction is disabled, Compiled individually collects the sheets (from Components), and put them in the <Head>
. Note this is done on client-side.
Mm I think style groups are still ordered when ran in runtime mode. Let me look.
Edit: https://github.com/atlassian-labs/compiled/blob/master/packages/react/src/runtime/sheet.ts
Mm I think style groups are still ordered when ran in runtime mode. Let me look.
Yea, but I think ordering the breakpoints on client-side is going to be quite a runtime cost.
True.
I can think of two options:
Option 1: Ask the users of Compiled to avoid overlapping breaking points
const style = css({
"@media (min-width: 10px and max-width: 19px)": {
color: "red"
},
"@media (min-width: 20px)": {
color: "green"
}
})
Option 2: Sort the media query by break points somehow.
I will take a look how Stylex does it.
Compiled uses Atomic CSS, so the order of CSS rules is not based on the definition in the codebase. This means
in the :point_up:, the order of these two pieces of CSS rules are not guaranteed. Can we order the Media Query CSS, so they are always mobile first?
Implementation detail: Create a postcss plugin to sort media queries.