Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media query option to preserver order #92

Closed
wants to merge 2 commits into from
Closed

Media query option to preserver order #92

wants to merge 2 commits into from

Conversation

erikthalen
Copy link
Contributor

As in #30, our media queries got re-ordered when running this plugin.

I've added an option to preserve at-rule-order, which makes it all good again. In the current project I'm on we're developing mobile first and it's crucial that the smaller @media-rule doesn't overwrite the bigger one (which should come after the first one).

When the new option is true:

options = {
    preserveAtRulesOrder: true
}

all the at-rules will be inserted in the CSS after the previously computed one. Instead of being inserted right after the parent selector. The new option should be used when using min-widths, and should be set to false when using max-widths.

The new option defaults to false, meaning no change from how the plugin behaved before.

Copy link

@AndyWilson82 AndyWilson82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment regarding expected behaviour and making the rules preserve order by default. Happy to approve the changes as the fix works as expected.

shouldPreserve = shouldPreserve || false;
preserveAtRulesOrder = preserveAtRulesOrder || false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the expected behaviour would be to maintain the CSS rule order. Therefore, would this make more sense defaulting to true?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awilson82-vp I am in favor of making the default be in order as expected. We can make a major release to play nice for people who have already worked around it.

Even removing the option completely seems reasonable

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MadLittleMods Could we release this new option as-is now (minor release), and then change default to true in the next major release? That would allow us to start using it immediately.
Happy to help out if anything else needs to be done before this can be released.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dampkwab We can do a major release now (no need to wait for anything else). We just need to update the default in this PR.

A minor release is just extra work for no reason.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MadLittleMods I've updated the default now - hope that helps :)
#100

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#100 (comment) is now abandoned

I created #101 which removes the playground/ changes so we can build fresh from master. It seems like we should have some more tests though. So someone will need to pick that up

If we updated this merge request default to true, all of the current tests would need to be updated which would give us nice coverage.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MadLittleMods
Uff, I really need this fix ASAP =D
What about sticking with harmless preserveAtRulesOrder=false as default until you finish your wished result ^^)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dinodujmovic Sure 🤷‍♀ , now published: #92 (comment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot !

@MadLittleMods
Copy link
Owner

MadLittleMods commented Jan 31, 2019

@erikthalen Sorry for not reviewing this sooner ❤️. Thanks for the fix!

@awilson82-vp Thanks for taking a look 💯

@MadLittleMods MadLittleMods changed the title Media query option Media query option to preserver order Jan 31, 2019
@luiscarlosjayk
Copy link

First of all, thanks for your work.
Second, please release this, need it to being able to fix issues in old browsers, which this postcss plugin helps to solve.

@patmead
Copy link

patmead commented May 23, 2019

@Ciul I've moved to using postcss-preset-env instead - it only supports variable declarations on :root but at least it doesn't break your @media rules by putting them in the wrong order.

@MadLittleMods MadLittleMods mentioned this pull request May 28, 2019
@MadLittleMods
Copy link
Owner

Closing as we haven't got a response from @erikthalen

#101 holds the latest of this if someone wants to pick it up again

MadLittleMods added a commit that referenced this pull request Jun 17, 2019
@MadLittleMods
Copy link
Owner

This was merged via #101 and is now published in postcss-css-variables@0.13.0, https://www.npmjs.com/package/postcss-css-variables

Thanks @erikthalen for the contribution ❤️

@erikthalen
Copy link
Contributor Author

Thanks @erikthalen for the contribution ❤️

Glad I could help!

@fredrikekelund
Copy link

Wanted to extend a big and sincere thank you for this, @erikthalen (and @MadLittleMods)! Made our workflow a lot smoother.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants