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

Misses programmatically-defined variables #153

Closed
chris-morgan opened this issue Mar 31, 2017 · 3 comments
Closed

Misses programmatically-defined variables #153

chris-morgan opened this issue Mar 31, 2017 · 3 comments
Labels
type: feature New feature or request
Milestone

Comments

@chris-morgan
Copy link

chris-morgan commented Mar 31, 2017

This is acting separately of the map that postcss-custom-properties maintains, instead looking for all :root rules and parsing custom properties in them itself.

The effect of this is that when you have programmatically-inserted custom properties, like with customProperties({variables: {key: 'value'}}), @if var(--key) { } doesn’t work, because the declaration of those variables isn’t injected into the CSS at all.

(Also the error message isn’t exactly the nicest—it just leaves it alone, so that you get “Failed to parse expression” from postcss-conditionals.)

Fixing this will need to be done in collaboration with postcss-custom-properties, because that plugin doesn’t expose its properties map at all and it will need to. postcss/postcss-custom-properties#66 covers their side of this.

@Scrum
Copy link
Owner

Scrum commented Mar 31, 2017

@chris-morgan thanks for feedback, i`ll think.

@Scrum Scrum added the type: feature New feature or request label Mar 31, 2017
@Scrum Scrum added this to the 0.1.0 milestone Apr 5, 2017
Scrum added a commit that referenced this issue Apr 5, 2017
Scrum added a commit that referenced this issue Apr 5, 2017
@Scrum
Copy link
Owner

Scrum commented Apr 5, 2017

@chris-morgan Hi, I added programmatically-defined variables as an option, now you can use it just like in postcss-custome-property

const options = {variables: {foo:'bar'}};
...
atRulesVariables(options)
customProperties(options)
...

In any case, let me know what you think about it.

@chris-morgan
Copy link
Author

That’s a good workaround in the absence of proper support from postcss-custom-properties. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants