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

Calculations with params only work with interpolation #46

Open
baldvinhansson opened this issue Mar 8, 2022 · 2 comments
Open

Calculations with params only work with interpolation #46

baldvinhansson opened this issue Mar 8, 2022 · 2 comments

Comments

@baldvinhansson
Copy link

Just in case someone is battling this issue.

height: calc(100vh - $header-height);
will not work - however

height: calc(100vh - #{$header-height});
does work.

Not sure if this is a bug in WebOptimizer.Sass or if maybe I've been writing incorrect SCSS to this date. The syntax without interpolation worked fine in the WebCompiler VS extension but had to be changed when I started using WebOptimizer.

@HybridSolutions
Copy link

HybridSolutions commented Mar 17, 2022

According to Sass documentation

You can also use [interpolation](https://sass-lang.com/documentation/interpolation) in a calculation. However, if you do, nothing in the parentheses that surround that interpolation will be simplified or type-checked, so it’s easy to end up with extra verbose or even invalid CSS. Rather than writing calc(10px + #{$var}), just write calc(10px + $var)!

you are correct. Are you getting an error?

@baldvinhansson
Copy link
Author

Yes, assuming $var: 10px for instance. The code height: calc(100vh - $var); renders as height: calc(100vh - $var); instead of height: calc(100vh - 10px);

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

No branches or pull requests

2 participants