Comments (12)
According to specs you cannot do that. Media queries are different than properties values that can changes with cascade. @tabatkins gave me a pretty good explanation once, cannot remember completely nor find it :/
from postcss-custom-media.
Right. "Variables" are just custom properties. Properties apply to elements, and the var()
function takes the value of the corresponding property on the element and substitutes it in.
@media
isn't an element, and so doesn't have any property to take from.
from postcss-custom-media.
interesting and understood. Any thoughts on ways to manage custom media values? I'm using a modular scale for sizing, and it essentially gives a list of sizes in em
. Do I really have to manually put in the value? Feels archaic :-)
from postcss-custom-media.
Looks like I could use something like postcss-simple-vars to do the trick. Thanks and sorry for the false alarm!
from postcss-custom-media.
Note as well that the CSSWG is developing custom media queries http://dev.w3.org/csswg/mediaqueries/#custom-mq which'll help you out natively.
from postcss-custom-media.
@tabatkins not really - as far as I understand it, I will have to supply the actual value to the custom media query when I'm creating it, so I couldn't do something like:
:root {
--ms6: 4.5em;
}
@custom-media --palm (min-width: var(--ms6));
@media (--palm) {
html {
color: red !important;
}
}
from postcss-custom-media.
Yes, you have to put the value into the MQ. If you're using the value in both Variables and MQs, you'll have to repeat it. CSS is unlikely to sprout macros that allow you to substitute values into arbitrary contexts.
from postcss-custom-media.
@MoOx looks like it doesn't even work with postcss-simple-vars:
INPUT:
@custom-media --palm (min-width: $palm);
@media (--palm) {
html {
background: red !important;
}
}
OUTPUT:
@media (min-width: $palm) {
html {
background: red !important;
}
}
from postcss-custom-media.
@VinSpee very strange, because simple vars should support variables in custom at-rules.
What is your plugins order? Can you show me how you define $palm
?
from postcss-custom-media.
@ai node.params.indexOf('$(')
you look for $(
.
postcss-custom-media is doing his job here so I am closing this issue.
from postcss-custom-media.
@MoOx nope, I call bothSyntax
function for params. But you are right, it is relevant to simple-vars.\
@VinSpee please open issue here https://github.com/postcss/postcss-simple-vars/issues/new
from postcss-custom-media.
I opened postcss/postcss-simple-vars#3 which is causing this issue. Thanks all
from postcss-custom-media.
Related Issues (20)
- Incorrect expansion of @custom-media within import '...' $media-query HOT 1
- File-based modularised definitions not propagating up. HOT 9
- How to specify a range instead of min/max width? HOT 1
- min-width & max-width HOT 2
- How can I use custom media with design tokens? HOT 2
- Please add the option for disable all warnings HOT 3
- PostCSS 7 conflicts HOT 5
- 7.0 regression HOT 1
- 7.0 - media types not working HOT 2
- "extensions" option lost since new versions? HOT 7
- Broken AND operator since 7.x.x HOT 4
- Version 7.0.5 not being published to npm HOT 2
- Help understanding changes from v6 to v7 HOT 6
- 7.0.6 broke my css HOT 1
- Breakpoints not working properly HOT 2
- Can't import queries from .pcss file HOT 1
- Media Queries not working HOT 2
- Can't use custom-media if it's defined inside node_modules HOT 1
- Is it possible to interpolate values for custom media? HOT 4
- Use PostCSS 8 events HOT 7
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 postcss-custom-media.