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

Units should not be removed from CSS variables. #286

Closed
jgerigmeyer opened this issue Sep 29, 2016 · 2 comments
Closed

Units should not be removed from CSS variables. #286

jgerigmeyer opened this issue Sep 29, 2016 · 2 comments

Comments

@jgerigmeyer
Copy link
Contributor

jgerigmeyer commented Sep 29, 2016

I have a problem very similar to MoOx/reduce-css-calc#7, except I'm storing 0px in a CSS variable and then using that in a calc() statement:

--my-variable: 0px;
min-height: calc(100vh - var(--my-variable));

By default, cssnano strips the variable down to 0, which makes the resulting calc() statement invalid.

I can fix this by disabling the convertValues option, but it's unfortunate to remove that everywhere just for one case. Because CSS variables could be used in various places where the units might matter, shouldn't they be left intact?

@ben-eb
Copy link
Collaborator

ben-eb commented Sep 29, 2016

Hi @jgerigmeyer,

Sure thing, the value is transformed irrespective of it being a custom property or not. Would you like to send a pull request to fix this behaviour, please? We would need a condition added to https://github.com/ben-eb/postcss-convert-values/blob/master/src/index.js#L46 that checks that the decl.prop begins with --, and then a test case for this in https://github.com/ben-eb/postcss-convert-values/blob/master/src/__tests__/index.js. This should not take much time to implement. 😄

@jgerigmeyer
Copy link
Contributor Author

PR submitted: https://github.com/ben-eb/postcss-convert-values/pull/33

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

2 participants