WebOptimizer.Sass icon indicating copy to clipboard operation
WebOptimizer.Sass copied to clipboard

Calculations with params only work with interpolation

Open baldvinhansson opened this issue 2 years ago • 2 comments

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.

baldvinhansson avatar Mar 08 '22 14:03 baldvinhansson

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?

HybridSolutions avatar Mar 17 '22 22:03 HybridSolutions

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

baldvinhansson avatar Mar 18 '22 10:03 baldvinhansson