Code Monkey home page Code Monkey logo

Comments (6)

KittyGiraudel avatar KittyGiraudel commented on May 18, 2024

I believe we could add further checking to make sure the generated media queries actually make sense but I am not eager to do it for simplicity reasons. I strongly believe it is not the responsibility of include-media to make sure the generated media queries actually match anything.

Maybe a plugin then.

from include-media.

nirazul avatar nirazul commented on May 18, 2024

I've yet to come across a real case, where this sort of nested media queries really makes sense.
If you have full control over your stylesheet, this will never be needed, as you can abstract anything into a range between two breakpoints. On the contrary, the example is ambiguous as I would have thought that the inner statements overwrite the outer ones because that's how the cascade works.

from include-media.

panec avatar panec commented on May 18, 2024

@nirazul I can agree that this example is ambiguous, as I'm understanding it differently, as the browsers are computing it - in a way that all conditions separated by and need to me met.

Another good example of it is this:

@media (min-width: 769px) and (max-width: 1024px) and (max-width: 321px) {
  width: 60%;
}

That will never be applied as max-width: 321px + min-width: 769px exclude themselves. In this case that rule should be removed from the css.

For the case in which it might occur is quite simple. Imagine that you got a mixin that got some include-media call inside and nest it inside another include-media closure. You do not have the visibility what is happening until the end css will be generated.
You can parametrise the mixin to allow generating code for each media query inside it but it will be prone to error and hard to maintain.

I agree with @hugogiraudel as it should be a part of another plugin / post generation step thou.

from include-media.

drazik avatar drazik commented on May 18, 2024

I think that instead of "rewrite" your media query if it contains some parts that exclude themselves, it should just warn you about it. Because it you end with such excluding media query, I bet it's because you made a mistake. And in this case, it must be a plugin.

from include-media.

panec avatar panec commented on May 18, 2024

To solve the issue that was mentioned I created a separate plugin as @hugogiraudel suggested. It is in PostCSS https://github.com/panec/postcss-mq-optimize

from include-media.

eduardoboucas avatar eduardoboucas commented on May 18, 2024

That's pretty cool, thanks for that. I'll close this then! 🎉

from include-media.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.