Skip to content

Commit 112925e

Browse files
authored
fix(scss): resolving sass deprecation warnings and compilation errors
1 parent 9e5a742 commit 112925e

7 files changed

Lines changed: 43 additions & 26 deletions

File tree

docs/assets/src/scss/_callouts.scss

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use 'sass:color';
2+
13
.bd-callout {
24
padding: 1.25rem;
35
margin-top: 1.25rem;
@@ -26,9 +28,9 @@
2628

2729
// Variations
2830
@mixin bs-callout-variant($color) {
29-
border-left-color: darken($color, 10%);
31+
border-left-color: color.scale($color, $lightness: -10%);
3032
h4 {
31-
color: darken($color, 10%);
33+
color: color.scale($color, $lightness: -10%);
3234
}
3335
}
3436

@@ -38,6 +40,9 @@
3840

3941
.bd-callout-warning {
4042
@include bs-callout-variant($docs-warning);
43+
h4 {
44+
color: $color-text-warning;
45+
}
4146
}
4247

4348
.bd-callout-danger {
@@ -48,5 +53,5 @@
4853
h4 {
4954
color: $docs-accessibility;
5055
}
51-
border-left-color: lighten($docs-accessibility, 10%);
56+
border-left-color: color.scale($docs-accessibility, $lightness: 10%);
5257
}

docs/assets/src/scss/_colors.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Docs color palette classes
33
//
44

5+
@use 'sass:color';
6+
57
@each $color, $value in $colors {
68
.swatch-#{$color} {
79
color: color-contrast($value);
@@ -23,8 +25,8 @@
2325
}
2426
}
2527

26-
$primary-bright: lighten(saturate($primary, 5%), 15%) !default;
27-
$primary-light: lighten(saturate($primary, 5%), 45%) !default;
28+
$primary-bright: color.scale(color.scale($primary, $saturation: 5%), $lightness: 15%) !default;
29+
$primary-light: color.scale(color.scale($primary, $saturation: 5%), $lightness: 45%) !default;
2830
$docs-info: rgb(23, 50, 77) !default;
2931
$docs-warning: rgb(255, 151, 0) !default;
3032
$docs-danger: rgb(248, 62, 90) !default;

docs/assets/src/scss/_component-examples.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use 'sass:color';
2+
13
.bd-example-row {
24
.d-flex,
35
.row {
@@ -88,22 +90,22 @@
8890
.bd-example-container-header {
8991
height: 3rem;
9092
margin-bottom: 0.5rem;
91-
background-color: lighten($blue, 50%);
93+
background-color: color.scale($blue, $lightness: 50%);
9294
border-radius: 0.25rem;
9395
}
9496

9597
.bd-example-container-sidebar {
9698
float: right;
9799
width: 4rem;
98100
height: 8rem;
99-
background-color: lighten($blue, 25%);
101+
background-color: color.scale($blue, $lightness: 25%);
100102
border-radius: 0.25rem;
101103
}
102104

103105
.bd-example-container-body {
104106
height: 8rem;
105107
margin-right: 4.5rem;
106-
background-color: lighten($primary, 25%);
108+
background-color: color.scale($primary, $lightness: 25%);
107109
border-radius: 0.25rem;
108110
}
109111

src/scss/base/_functions.scss

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
//
33
// Utility mixins and functions for evaluating source code across our variables, maps, and mixins.
44

5+
@use 'sass:meta';
6+
@use 'sass:color';
7+
@use 'sass:math';
8+
59
// Ascending
610
// Used to evaluate Sass maps like our grid breakpoints.
711
@mixin _assert-ascending($map, $map-name) {
@@ -34,7 +38,7 @@
3438

3539
// Colors
3640
@function to-rgb($value) {
37-
@return red($value), green($value), blue($value);
41+
@return color.channel($value, 'red', $space: rgb), color.channel($value, 'green', $space: rgb), color.channel($value, 'blue', $space: rgb);
3842
}
3943

4044
// stylelint-disable scss/dollar-variable-pattern
@@ -209,9 +213,9 @@ $_luminance-list: 0.0008 0.001 0.0011 0.0013 0.0015 0.0017 0.002 0.0022 0.0025 0
209213
// See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
210214
@function luminance($color) {
211215
$rgb: (
212-
'r': red($color),
213-
'g': green($color),
214-
'b': blue($color),
216+
'r': math.round(color.channel($color, 'red', $space: rgb)),
217+
'g': math.round(color.channel($color, 'green', $space: rgb)),
218+
'b': math.round(color.channel($color, 'blue', $space: rgb)),
215219
);
216220

217221
@each $name, $value in $rgb {
@@ -230,18 +234,18 @@ $_luminance-list: 0.0008 0.001 0.0011 0.0013 0.0015 0.0017 0.002 0.0022 0.0025 0
230234
// Return opaque color
231235
// opaque(#fff, rgba(0, 0, 0, .5)) => #808080
232236
@function opaque($background, $foreground) {
233-
@return mix(rgba($foreground, 1), $background, opacity($foreground) * 100%);
237+
@return color.mix(rgba($foreground, 1), $background, opacity($foreground) * 100%);
234238
}
235239

236240
// scss-docs-start color-functions
237241
// Tint a color: mix a color with white
238242
@function tint-color($color, $weight) {
239-
@return mix(white, $color, $weight);
243+
@return color.mix(white, $color, $weight);
240244
}
241245

242246
// Shade a color: mix a color with black
243247
@function shade-color($color, $weight) {
244-
@return mix(black, $color, $weight);
248+
@return color.mix(black, $color, $weight);
245249
}
246250

247251
// Shade the color if the weight is positive, else tint it
@@ -260,7 +264,7 @@ $_luminance-list: 0.0008 0.001 0.0011 0.0013 0.0015 0.0017 0.002 0.0022 0.0025 0
260264
@return $value1;
261265
}
262266

263-
@if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
267+
@if meta.type-of($value1) == number and meta.type-of($value2) == number and math.compatible($value1, $value2) {
264268
@return $value1 + $value2;
265269
}
266270

@@ -280,11 +284,11 @@ $_luminance-list: 0.0008 0.001 0.0011 0.0013 0.0015 0.0017 0.002 0.0022 0.0025 0
280284
@return $value1;
281285
}
282286

283-
@if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
287+
@if meta.type-of($value1) == number and meta.type-of($value2) == number and math.compatible($value1, $value2) {
284288
@return $value1 - $value2;
285289
}
286290

287-
@if type-of($value2) != number {
291+
@if meta.type-of($value2) != number {
288292
$value2: unquote('(') + $value2 + unquote(')');
289293
}
290294

src/scss/base/_variables.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Import Design Tokens Italia
22
// @import '../../node_modules/design-tokens-italia/scss/variables';
33

4+
@use 'sass:map';
5+
46
// Color vars
57
// HSB (https://it.wikipedia.org/wiki/Hue_Saturation_Brightness, coincidente con il modello HSV)
68
// è lo spazio colore scelto per ottenere le varianti colore della tonalità primaria.
@@ -21,7 +23,7 @@ $gray-800: hsl(0, 0%, 15%) !default; // color-gray-15
2123
$gray-900: hsl(0, 0%, 10%) !default; // color-gray-10
2224

2325
$grays: () !default;
24-
$grays: map-merge(
26+
$grays: map.merge(
2527
(
2628
'100': $gray-100,
2729
'200': $gray-200,
@@ -89,7 +91,7 @@ $gray-border-disabled: $gray-disabled !default; // color-border-disabled
8991
$secondary: $gray-secondary !default;
9092

9193
$colors: () !default;
92-
$colors: map-merge(
94+
$colors: map.merge(
9395
(
9496
'indigo': $indigo,
9597
'purple': $purple,
@@ -121,7 +123,7 @@ $warning: $orange-accessible !default;
121123
$danger: $red-accessible !default;
122124

123125
$theme-colors: () !default;
124-
$theme-colors: map-merge(
126+
$theme-colors: map.merge(
125127
(
126128
'primary': $primary,
127129
'secondary': $secondary,
@@ -412,7 +414,7 @@ $neutral-2-a7: hsb($neutral-2-h, $neutral-2-s + 4, $neutral-2-b - 85) !default;
412414
// Backgrounds
413415
$color-background-emphasis: hsl(210, 54%, 20%); // color-slate-20
414416
$color-background-primary-lighter: hsl(210, 62%, 97%); // color-blue-97
415-
$color-background-primary-hover: hsl(210, 100, 30); // color-blue-30
417+
$color-background-primary-hover: hsl(210, 100%, 30%); // color-blue-30
416418
$color-background-secondary-hover: hsl(210, 33%, 28%); // color-slate-28
417419
$color-background-secondary-lighter: hsl(210, 3%, 85%); // color-slate-85
418420
$color-background-muted: $gray-100; // color-gray-96
@@ -1966,7 +1968,7 @@ $grid-list-text-gap: $v-gap;
19661968
$grid-item-sm-col: 50%;
19671969
$grid-item-lg-col: 33.333333%;
19681970
$grid-item-icon-size: 24px;
1969-
$grid-item-overlay: hsla(210%, 54%, 20, 0.85);
1971+
$grid-item-overlay: hsla(210deg, 54%, 20%, 0.85);
19701972

19711973
// list
19721974
$list-font-size: 1rem;

src/scss/base/vendor/_rfs.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// stylelint-disable property-blacklist, scss/dollar-variable-default
22

3+
@use 'sass:meta';
4+
35
// SCSS RFS mixin
46
//
57
// Automated responsive values for font sizes, paddings, margins and much more
@@ -30,7 +32,7 @@ $rfs-two-dimensional: false !default;
3032
// Factor of decrease
3133
$rfs-factor: 10 !default;
3234

33-
@if type-of($rfs-factor) != number or $rfs-factor <= 1 {
35+
@if meta.type-of($rfs-factor) != number or $rfs-factor <= 1 {
3436
@error "`#{$rfs-factor}` is not a valid $rfs-factor, it must be greater than 1.";
3537
}
3638

src/scss/components/_chips.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
border-radius: $v-gap * 1.5;
99
height: $v-gap * 3;
1010
min-width: 100px;
11-
padding: 0 $v-gap / 2 2px $v-gap;
11+
padding: 0 calc($v-gap / 2) 2px $v-gap;
1212
transition: all 0.05s;
1313
margin-top: $v-gap * 0.5;
1414
margin-bottom: $v-gap;
@@ -67,7 +67,7 @@
6767
height: $v-gap * 4;
6868
min-width: 120px;
6969
border-radius: $v-gap * 2;
70-
padding: 2px $v-gap / 2 0 $v-gap * 2;
70+
padding: 2px calc($v-gap / 2) 0 $v-gap * 2;
7171
//label
7272
.chip-label {
7373
font-size: $chips-label-font-size-l;

0 commit comments

Comments
 (0)