Use multiplications instead of divisions in Sass variables

In the previous commit, we used the `calc` function when assiging CSS
properties in order to avoid 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($global-width, 2) or calc($global-width / 2)
```

In cases like dividing by two, there's a third alternative: multiplying
by 0.5. We're applying this principle to all variable assignments where
we were using divisions, since using the `calc` function here would
sometimes result in errors due to these variables being used in
arithmetical operations. We aren't using `math.div` because it makes the
code harder to read.
This commit is contained in:
Javi Martín
2024-03-27 21:37:27 +01:00
parent 6df813fdb6
commit 1a797f2808
12 changed files with 18 additions and 18 deletions

View File

@@ -53,8 +53,8 @@ $show-header-for-stacked: true !default;
// 2. CONSUL DEMOCRACY variables // 2. CONSUL DEMOCRACY variables
// ----------------------------- // -----------------------------
$body-margin: calc(50vw - #{$global-width / 2}) !default; $body-margin: calc(50vw - #{$global-width * 0.5}) !default;
$full-width-margin: unquote("#{$global-width / 2} - 50vw") !default; $full-width-margin: unquote("#{$global-width * 0.5} - 50vw") !default;
$base-font-size: rem-calc(17) !default; $base-font-size: rem-calc(17) !default;
$base-line: rem-calc(26) !default; $base-line: rem-calc(26) !default;
@@ -160,7 +160,7 @@ $anchor-color-hover: darken($anchor-color, 20%) !default;
$tab-background-active: $white !default; $tab-background-active: $white !default;
$tab-item-font-size: $base-font-size !default; $tab-item-font-size: $base-font-size !default;
$tab-item-padding: $line-height / 2 0 !default; $tab-item-padding: $line-height * 0.5 0 !default;
$tab-content-border: $border !default; $tab-content-border: $border !default;
$tooltip-background-color: $brand !default; $tooltip-background-color: $brand !default;

View File

@@ -436,7 +436,7 @@ $input-background-focus: $white !default;
$input-background-disabled: $light-gray !default; $input-background-disabled: $light-gray !default;
$input-border: 1px solid $medium-gray !default; $input-border: 1px solid $medium-gray !default;
$input-border-focus: 1px solid $dark-gray !default; $input-border-focus: 1px solid $dark-gray !default;
$input-padding: $form-spacing / 2 !default; $input-padding: $form-spacing * 0.5 !default;
$input-shadow: inset 0 1px 2px rgba($black, 0.1) !default; $input-shadow: inset 0 1px 2px rgba($black, 0.1) !default;
$input-shadow-focus: 0 0 5px $medium-gray !default; $input-shadow-focus: 0 0 5px $medium-gray !default;
$input-cursor-disabled: not-allowed !default; $input-cursor-disabled: not-allowed !default;
@@ -778,7 +778,7 @@ $table-row-stripe-hover: darken($table-background, $table-color-scale + $table-h
$table-is-striped: true !default; $table-is-striped: true !default;
$table-striped-background: smart-scale($table-background, $table-color-scale) !default; $table-striped-background: smart-scale($table-background, $table-color-scale) !default;
$table-stripe: even !default; $table-stripe: even !default;
$table-head-background: smart-scale($table-background, $table-color-scale / 2) !default; $table-head-background: smart-scale($table-background, $table-color-scale * 0.5) !default;
$table-head-row-hover: darken($table-head-background, $table-hover-scale) !default; $table-head-row-hover: darken($table-head-background, $table-hover-scale) !default;
$table-foot-background: smart-scale($table-background, $table-color-scale) !default; $table-foot-background: smart-scale($table-background, $table-color-scale) !default;
$table-foot-row-hover: darken($table-foot-background, $table-hover-scale) !default; $table-foot-row-hover: darken($table-foot-background, $table-hover-scale) !default;

View File

@@ -1,7 +1,7 @@
.admin .budgets-actions { .admin .budgets-actions {
> * { > * {
$gap: $line-height; $gap: $line-height;
$vertical-gap: $line-height / 2; $vertical-gap: $line-height * 0.5;
@include flex-with-gap($gap); @include flex-with-gap($gap);
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;

View File

@@ -1,6 +1,6 @@
.admin .drafting { .admin .drafting {
$vertical-gap: nth($callout-margin, 3); $vertical-gap: nth($callout-margin, 3);
@include flex-with-gap($line-height / 2); @include flex-with-gap($line-height * 0.5);
align-items: flex-start; align-items: flex-start;
flex-wrap: wrap; flex-wrap: wrap;
margin-bottom: $line-height * 1.5; margin-bottom: $line-height * 1.5;

View File

@@ -1,7 +1,7 @@
.admin .budgets-help { .admin .budgets-help {
$padding: $line-height / 2; $padding: $line-height * 0.5;
$quote-size: 1em; $quote-size: 1em;
$quote-padding: 2 * $quote-size / 5; $quote-padding: $quote-size * 0.4;
$quote-width: $quote-size + 2 * $quote-padding; $quote-width: $quote-size + 2 * $quote-padding;
@include has-fa-icon(quote-right, solid, after); @include has-fa-icon(quote-right, solid, after);

View File

@@ -1,5 +1,5 @@
.ballot-list li { .ballot-list li {
$side-padding: $line-height / 2; $side-padding: $line-height * 0.5;
$close-icon-size: rem-calc(20); $close-icon-size: rem-calc(20);
$close-icon-margin: rem-calc(6); $close-icon-margin: rem-calc(6);

View File

@@ -1,5 +1,5 @@
.public .groups-and-headings { .public .groups-and-headings {
$spacing: $line-height / 2; $spacing: $line-height * 0.5;
.headings-list { .headings-list {
@include flex-with-gap($spacing); @include flex-with-gap($spacing);

View File

@@ -1,8 +1,8 @@
.in-favor-against { .in-favor-against {
@include flex-with-gap($line-height / 4); @include flex-with-gap($line-height * 0.25);
@include breakpoint(medium) { @include breakpoint(medium) {
@include flex-with-gap($line-height * 3 / 4); @include flex-with-gap($line-height * 0.75);
} }
&, &,

View File

@@ -22,7 +22,7 @@
$icon-size: $line-height * 4; $icon-size: $line-height * 4;
$padding-right: rem-calc(20); $padding-right: rem-calc(20);
$icon-size-with-padding: $icon-size + $padding-right; $icon-size-with-padding: $icon-size + $padding-right;
$polygon-size: $icon-size / 2; $polygon-size: $icon-size * 0.5;
@include background-till-left-of-screen; @include background-till-left-of-screen;
@include brand-secondary-background; @include brand-secondary-background;
border: $border-width solid $brand-secondary; border: $border-width solid $brand-secondary;

View File

@@ -33,7 +33,7 @@
} }
@mixin full-width-cover($adjust-margin: true, $adjust-padding: false) { @mixin full-width-cover($adjust-margin: true, $adjust-padding: false) {
$global-padding: rem-calc(map-get($grid-column-gutter, medium)) / 2; $global-padding: rem-calc(map-get($grid-column-gutter, medium)) * 0.5;
bottom: 0; bottom: 0;
content: ""; content: "";
display: block; display: block;
@@ -44,7 +44,7 @@
top: 0; top: 0;
@if $adjust-padding { @if $adjust-padding {
$small-padding: rem-calc(map-get($grid-column-gutter, small)) / 2; $small-padding: rem-calc(map-get($grid-column-gutter, small)) * 0.5;
left: -$small-padding; left: -$small-padding;
right: -$small-padding; right: -$small-padding;

View File

@@ -1,5 +1,5 @@
@mixin sdg-goal-list($spacing: 1ch) { @mixin sdg-goal-list($spacing: 1ch) {
$min-spacing: $sdg-icon-min-width / 10; $min-spacing: $sdg-icon-min-width * 0.1;
$max-spacing: #{"Max(#{$min-spacing}, #{$spacing})"}; $max-spacing: #{"Max(#{$min-spacing}, #{$spacing})"};
display: flex; display: flex;

View File

@@ -1643,7 +1643,7 @@
} }
.poll-question-answers { .poll-question-answers {
@include flex-with-gap($line-height / 4); @include flex-with-gap($line-height * 0.25);
flex-wrap: wrap; flex-wrap: wrap;
.button { .button {