Open mikestreety opened 7 years ago
@mikestreety Can you provide the output after the @include
plugin runs so we know exactly what is being passed into postcss-css-variables
? Also would help to add a full expected snippet instead of just explaining.
Ah sorry, it was where I was copying and pasting. It just expands into a media query.
So:
:root {
--gutter: 1rem;
--gutterLarge: 2rem;
@media (min-width: 46.25em) {
--gutter: 1.5rem;
--gutterLarge: 3rem;
}
@media (min-width: 61.25em) {
--gutterLarge: 4rem;
}
}
div {
padding: var(--gutter) var(--gutterLarge);
}
div {
padding: 1rem 2rem;
}
@media (min-width: 46.25em) {
div {
padding: 1.5rem 3rem;
}
}
@media (min-width: 61.25em) {
div {
padding: 1rem 4rem;
}
}
div {
padding: 1rem 2rem;
}
@media (min-width: 46.25em) {
div {
padding: 1.5rem 3rem;
}
}
@media (min-width: 61.25em) {
div {
padding: 1.5rem 4rem;
}
}
Note the padding in the last media query
Thanks!
@mikestreety Are you sure that is the actual input and output? It looks like you are using a nesting plugin
It seems like the input/output would be the following which isn't very clean but does seem to have the respective padding: 1rem 2rem;
, padding: 1.5rem 3rem;
, padding: 1rem 4rem;
at various breakpoints as the last ones in the source which would apply.
:root {
--gutter: 1rem;
--gutterLarge: 2rem;
}
@media (min-width: 46.25em) {
:root {
--gutter: 1.5rem;
--gutterLarge: 3rem;
}
}
@media (min-width: 61.25em) {
:root {
--gutterLarge: 4rem;
}
}
div {
padding: var(--gutter) var(--gutterLarge);
}
div {
padding: 1rem 2rem;
}
@media (min-width: 61.25em) {
div {
padding: 1rem 4rem;
}
}
@media (min-width: 46.25em) {
div {
padding: 1.5rem 3rem;
}
}
@media (min-width: 46.25em) {
div {
padding: 1.5rem 3rem;
}
}
@media (min-width: 61.25em) {
div {
padding: 1rem 4rem;
}
}
@media (min-width: 46.25em) {
div {
padding: 1.5rem 3rem;
}
}
@media (min-width: 46.25em) {
div {
padding: 1.5rem 3rem;
}
}
Sorry, I don't seem to be very good at this 😉 - the input is also processed by SCSS.
I will isolate the plugin and do some tests and get back to you 👍
Quite a confusing title, I apologise. Essentially, if a variable is declared and altered in a MQ and then mixed in the same declaration as one that isn't, it falls back to its original value.
This will output:
I would expect the last one to be
1.5rem 4rem
.