Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Merge branch 'main' into fix-media-query-specificity

Oleg Isonenc62529860562
diff --cc packages/css-engine/src/core/css-engine.ts
index 27c042d5e4,cccee8b978..51f977d7c3
--- a/packages/css-engine/src/core/css-engine.ts
+++ b/packages/css-engine/src/core/css-engine.ts
@@@ -80,9 -82,11 +82,11 @@@ export class CssEngine
for (const plaintextRule of this.#plainRules.values()) {
css.push(plaintextRule.cssText);
}
- for (const mediaRule of this.#mediaRules.values()) {
+ for (const mediaRule of MediaRule.sort(this.#mediaRules.values())) {
const { cssText } = mediaRule;
- if (cssText !== "") css.push(cssText);
+ if (cssText !== "") {
+ css.push(cssText);
+ }
}
this.#cssText = css.join("\n");
return this.#cssText;
diff --cc packages/css-engine/src/core/rules.ts
index 57945cfcf2,d63d6a6abd..eb3f218156
--- a/packages/css-engine/src/core/rules.ts
+++ b/packages/css-engine/src/core/rules.ts
@@@ -92,10 -85,16 +96,16 @@@ export class MediaRule
rules.push(` ${rule.cssText}`);
}
let conditionText = "";
- const { minWidth, maxWidth } = this.#options;
+ const { minWidth, maxWidth } = this.options;
- if (minWidth !== undefined) conditionText = `min-width: ${minWidth}px`;
- if (maxWidth !== undefined) conditionText = `max-width: ${maxWidth}px`;
- if (conditionText) conditionText = `and (${conditionText}) `;
+ if (minWidth !== undefined) {
+ conditionText = `min-width: ${minWidth}px`;
+ }
+ if (maxWidth !== undefined) {
+ conditionText = `max-width: ${maxWidth}px`;
+ }
+ if (conditionText) {
+ conditionText = `and (${conditionText}) `;
+ }
return `@media ${this.#mediaType} ${conditionText}{\n${rules.join(
"\n"
)}\n}`;