Use calc() where divisions are involved

The division operator `/` from Sass is deprecated because `/` is used in
CSS for uses other than dividing numbers. That's why we were getting
many warnings like:

```
Deprecation Warning: Using / for division outside of calc() is
deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($line-height, 2) or calc($line-height / 2)

More info and automated migrator: https://sass-lang.com/d/slash-div

margin-top: $line-height / 2;
```

Since using math.div makes the code harder to read and `calc` is
universally supported by all browsers (although the implementation in
Internet Explorer doesn't work in certain cases), we're using `calc`
when assigning the value to a CSS property.

However, we're also using divisions when assigning Sass variables, and
in those cases using `calc` is trickier because sometimes these
variables are used in other operations. We'll handle these cases in the
next commit.
This commit is contained in:
Javi Martín
2024-03-27 21:33:09 +01:00
parent d54971e536
commit 6df813fdb6
54 changed files with 214 additions and 214 deletions

View File

@@ -30,7 +30,7 @@ $progress-bar-color: #fea230;
}
.milestone-progress .row {
margin-bottom: $line-height / 2;
margin-bottom: calc(#{$line-height} / 2);
}
}
}
@@ -68,7 +68,7 @@ $progress-bar-color: #fea230;
}
.milestone-content {
padding: $line-height / 6 $line-height / 2;
padding: calc(#{$line-height} / 6) calc(#{$line-height} / 2);
position: relative;
@include breakpoint(medium) {
@@ -121,6 +121,6 @@ $progress-bar-color: #fea230;
@include background-with-text-contrast($budget);
border-radius: rem-calc(4);
display: inline-block;
margin-top: $line-height / 6;
padding: $line-height / 4 $line-height / 2;
margin-top: calc(#{$line-height} / 6);
padding: calc(#{$line-height} / 4) calc(#{$line-height} / 2);
}