Skip to content

Commit 161a482

Browse files
committed
chore(sass): minimal deprecation fixes (darken, lighten, math.div)
1 parent f6d4f0e commit 161a482

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

scss/_defs.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: MIT
33

44
// sizes
5-
$em: (18 / 16) * 1rem;
5+
$em: calc(18 / 16) * 1rem;
66
$spacing: 18px;
77

88
// fonts

scss/_forms.scss

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ label {
6161
input[type="submit"],
6262
input[type="reset"],
6363
button {
64-
background: darken($white, 5);
65-
color: darken($gray, 25);
64+
background: safe-adjust-lightness($white, -5);
65+
color: safe-adjust-lightness($gray, -25);
6666
cursor: pointer;
6767
display: inline;
6868
margin-bottom: $em;
@@ -71,16 +71,15 @@ button {
7171
text-align: center;
7272

7373
&:hover {
74-
background: darken($white, 15);
74+
background: safe-adjust-lightness($white, -15);
7575
color: $black;
7676
}
7777

7878
&[disabled] {
79-
background: darken($white, 10);
80-
color: darken($gray, 10);
79+
background: safe-adjust-lightness($white, -10);
80+
color: safe-adjust-lightness($gray, -10);
8181
cursor: not-allowed;
8282
}
83-
8483
}
8584

8685
input[type="submit"],
@@ -89,8 +88,8 @@ button[type="submit"] {
8988
color: $white;
9089

9190
&:hover {
92-
background: darken($blue, 15);
93-
color: darken($white, 25);
91+
background: safe-adjust-lightness($blue, -15);
92+
color: safe-adjust-lightness($white, -25);
9493
}
9594
}
9695

scss/_functions.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@use "sass:color";
2+
3+
/// Adjusts lightness of a color by a percentage.
4+
/// Positive `$percent` lightens, negative darkens.
5+
///
6+
/// @param {Color} $color - Base color.
7+
/// @param {Number} $percent - Percent to adjust lightness (e.g. 15 or -15).
8+
/// @return {Color} - Modified color.
9+
@function safe-adjust-lightness($color, $percent) {
10+
@return color.adjust($color, $lightness: $percent * 1%);
11+
}

scss/_grid.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ html {
2424
body {
2525
@extend %sans-serif;
2626
background: $white;
27-
color: lighten($black, 10);
27+
color: safe-adjust-lightness($black, 10);
2828
padding: 2 * $spacing;
2929
}
3030

@@ -62,7 +62,7 @@ footer {
6262

6363
article {
6464
background: $white;
65-
border: 1px solid lighten($black, 85);
65+
border: 1px solid safe-adjust-lightness($black, 85);
6666
}
6767

6868
nav {

scss/_pre.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ output {
1414
}
1515

1616
pre {
17-
border-left: .1 * $em solid lighten($green, 25);
17+
border-left: .1 * $em solid safe-adjust-lightness($green, 25);
1818
line-height: 1.4 * $em;
1919
overflow: auto;
2020
padding-left: $spacing;
@@ -29,7 +29,7 @@ pre {
2929

3030
code,
3131
kbd {
32-
background: lighten($green, 60);
32+
background: safe-adjust-lightness($green, 60);
3333
border-radius: .2 * $spacing;
3434
color: $green;
3535
display: inline-block;

scss/_tables.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ th {
1717

1818
thead th {
1919
border-bottom: .12 * $em solid $gray;
20-
border-left: .06 * $em solid lighten($black, 80);
20+
border-left: .06 * $em solid safe-adjust-lightness($black, 80);
2121
padding-bottom: .35 * $em;
2222

2323
&:first-child {
@@ -27,7 +27,7 @@ thead th {
2727

2828
tbody tr {
2929
&:hover {
30-
background-color: lighten($black, 98);
30+
background-color: safe-adjust-lightness($black, 98);
3131
}
3232
}
3333

scss/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: MIT
33

44
@import 'defs';
5+
@import 'functions';
56
@import 'common';
67
@import 'tables';
78
@import 'forms';

0 commit comments

Comments
 (0)