Comments (6)
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.
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.
@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.
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.
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.
That's pretty cool, thanks for that. I'll close this then! 🎉
from include-media.
Related Issues (20)
- [Documentation] Website down? https://include-media.com/ HOT 5
- Compiling error in IDE's with media(slice($conditions, 2)...) - possible fix HOT 4
- Migrate from @import to @use HOT 3
- Undefined mixin media HOT 1
- cannot import via `@use` HOT 13
- I made a library using this project, can I introduce it as a plugin? HOT 3
- include-media page on npm has a dodgy homepage field and link HOT 1
- How to use AND ? HOT 2
- Remove broken link HOT 1
- Define a default media-expression HOT 1
- Writing style HOT 2
- styled-components HOT 1
- DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0. HOT 7
- Help needed- setup HOT 7
- Release 2.0 on npm HOT 19
- Error on compiling HOT 8
- Container Queries? HOT 10
- Compability with current sass version? HOT 3
- `print` support HOT 1
- Using media with variables HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from include-media.