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

Using variable inside @media conditional not working #91

Open
klase opened this issue Jan 14, 2019 · 5 comments
Open

Using variable inside @media conditional not working #91

klase opened this issue Jan 14, 2019 · 5 comments

Comments

@klase
Copy link

klase commented Jan 14, 2019

The following does not compile properly (--container-max is set to 1200px):

@media (min-width: var(--container-max)) {
...
}

Expected:

@media (min-width: 1200px) {
...
}

Result:

@media (min-width: var(--container-max)) {
...
}
@Scrum
Copy link

Scrum commented Jan 31, 2019

@klase Hi, use postcss-at-rules-variables for at-rules because this feature in is the plans

@MadLittleMods
Copy link
Owner

MadLittleMods commented Jan 31, 2019

Thanks for the plugin suggestion @Scrum. Haven't tried but looks like you can run them together for now.

Seems like something this plugin could support as well if someone wants to submit a pull request 🤔

var postcss = require('postcss');
var cssvariables = require('postcss-css-variables');
var atVariables = require('postcss-at-rules-variables');

var fs = require('fs');

var mycss = fs.readFileSync('input.css', 'utf8');

// Process your CSS with postcss-css-variables
var output = postcss([
		cssvariables(/*options*/),
		atVariables({ /* atRules: ['media'] */ })
	])
	.process(mycss)
	.css;

console.log(output);

@Scrum
Copy link

Scrum commented Feb 1, 2019

@MadLittleMods Hi, It is more correct to use the atVariables plugin before the cssvariables plugin. there can be different iterations

var postcss = require('postcss');
var cssvariables = require('postcss-css-variables');
var atVariables = require('postcss-at-rules-variables');

var fs = require('fs');

var mycss = fs.readFileSync('input.css', 'utf8');

// Process your CSS with postcss-css-variables
var output = postcss([
		atVariables({ /* atRules: ['media'] */ })
		cssvariables(/*options*/),
	])
	.process(mycss)
	.css;

console.log(output);

Seems like something this plugin could support as well if someone wants to submit a pull request 🤔

we can install the Assignees on me and i will make as soon as time appears 👍

@MadLittleMods
Copy link
Owner

MadLittleMods commented Feb 1, 2019

@Scrum I can't assign a non-collaborator 😬

Just curious, why is it better to have postcss-at-rules-variables run first? It looks like it gets rid of the variable declarations that postcss-css-variables uses and I don't see a preserve option

@Scrum
Copy link

Scrum commented Feb 2, 2019

I can't assign a non-collaborator

ups ))

It looks like it gets rid of the variable declarations that postcss-css-variables uses and I don't see a preserve option

No, you can see the tests

Just curious, why is it better to have postcss-at-rules-variables run first?

Now I can not remember the case in which it was necessary

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

No branches or pull requests

3 participants