Skip to content

Commit c212a0f

Browse files
committed
refactor: convert Sass @import to @use/@forward module system
Migrate all Sass files from the deprecated @import rule to the modern @use/@forward module system: - @import -> @use with namespace or 'as *' for convenience - Create clay/_index.scss to re-export vars and mixins - _clay.scss forwards from the clay/ directory index - config-page.scss uses @use for each module Fix remaining Dart Sass deprecation warnings: - Slash division (/) -> math.div() or calc() - Global builtin ceil() -> sass:math.ceil() - Add @use 'sass:math' where needed
1 parent 33dd4db commit c212a0f

15 files changed

Lines changed: 55 additions & 41 deletions

src/styles/_clay.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
@import "clay/vars";
2-
@import "clay/mixins";
1+
@forward 'clay';

src/styles/clay/_base.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@import "clay";
1+
@use 'vars' as *;
2+
@use 'mixins' as *;
23

34
html, body {
45
@include font-pfdin(regular);
@@ -92,7 +93,7 @@ label {
9293
display: inline-block;
9394
color: $color-white;
9495
background: $color-orange;
95-
border-radius: $size / 2;
96+
border-radius: calc($size / 2);
9697
width: $size;
9798
text-align: center;
9899
height: $size;
@@ -152,8 +153,8 @@ label {
152153
display: block;
153154
position: absolute;
154155
top: 0;
155-
left: $item-spacing-h / 2;
156-
right: $item-spacing-h / 2;
156+
left: calc($item-spacing-h / 2);
157+
right: calc($item-spacing-h / 2);
157158
height: 1px;
158159
pointer-events: none;
159160
}

src/styles/clay/_index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@forward 'vars';
2+
@forward 'mixins';

src/styles/clay/_mixins.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@import "vars";
1+
@use 'sass:math';
2+
@use 'vars' as *;
23

34
@mixin font-pfdin($weight: normal) {
45

@@ -29,9 +30,9 @@
2930
}
3031

3132
@mixin font-size($size: 1) {
32-
$font-size: $size * 1rem;
33-
font-size:$font-size;
34-
line-height: $base-line-height * ceil($font-size / $base-line-height);
33+
$font-size: $size * 1rem;
34+
font-size: $font-size;
35+
line-height: $base-line-height * math.ceil(math.div($font-size, $base-line-height));
3536
}
3637

3738
@mixin tap-highlight($color: rgba(255, 255, 255, 0.1)) {

src/styles/clay/_vars.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
@use 'sass:math';
2+
13
// Base settings
24
$em-base: 17px;
35

4-
// custom vars
6+
// Custom vars
57
$base-line-height: 1.4;
68
$base-height: $base-line-height * $em-base;
79
$border-radius: 0.25rem;
8-
$item-spacing-v: $base-height / 2;
10+
$item-spacing-v: math.div($base-height, 2);
911
$item-spacing-h: 0.75rem;
1012
$golden: 1.618;
1113
$small-component-width: $base-height * $golden;

src/styles/clay/components/button.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use '../' as *;
2+
13
.component-button {
24
text-align: center;
35

src/styles/clay/components/checkboxgroup.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
@import "clay";
1+
@use 'sass:math';
2+
@use '../' as *;
23

34
.component-checkbox {
45

56
display: block;
67

78
.section & {
8-
padding-right: $item-spacing-h / 2;
9+
padding-right: math.div($item-spacing-h, 2);
910
}
1011

1112
> .label {
1213
display: block;
13-
padding-bottom: $item-spacing-v / 2;
14+
padding-bottom: math.div($item-spacing-v, 2);
1415
}
1516

1617
.checkbox-group {
1718

18-
padding-bottom: $item-spacing-v / 2;
19+
padding-bottom: math.div($item-spacing-v, 2);
1920

2021
label {
21-
padding: $item-spacing-v / 2 $item-spacing-h / 2;
22+
padding: math.div($item-spacing-v, 2) math.div($item-spacing-h, 2);
2223
}
2324

2425
.label {

src/styles/clay/components/color.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@import "clay";
1+
@use 'sass:math';
2+
@use '../' as *;
23

34
.component-color {
45

@@ -9,7 +10,7 @@
910
.value {
1011
width: $small-component-width;
1112
height: $base-height;
12-
border-radius: $base-height / 2;
13+
border-radius: math.div($base-height, 2);
1314
box-shadow: $box-shadow-small-components;
1415
display: block;
1516
background: #000;
@@ -21,7 +22,7 @@
2122
right: 0;
2223
bottom: 0;
2324
position: fixed;
24-
padding: $item-spacing-v $item-spacing-h /2;
25+
padding: $item-spacing-v math.div($item-spacing-h, 2);
2526
background: rgba(0, 0, 0, 0.65);
2627
opacity: 0;
2728
transition: opacity 100ms ease-in 175ms;

src/styles/clay/components/input.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@import "clay";
1+
@use 'sass:math';
2+
@use '../' as *;
23

34
.component-input {
45

@@ -26,7 +27,7 @@
2627
width: 100%;
2728
background: $color-gray-2;
2829
border-radius: $border-radius;
29-
padding: $item-spacing-v / 2 $item-spacing-h / 2;
30+
padding: math.div($item-spacing-v, 2) math.div($item-spacing-h, 2);
3031
border: none;
3132
vertical-align: baseline;
3233
color: $color-white;

src/styles/clay/components/radiogroup.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
@import "clay";
1+
@use 'sass:math';
2+
@use '../' as *;
23

34
.component-radio {
45

56
display: block;
67

78
.section & {
8-
padding-right: $item-spacing-h / 2;
9+
padding-right: math.div($item-spacing-h, 2);
910
}
1011

1112
> .label {
1213
display: block;
13-
padding-bottom: $item-spacing-v / 2;
14+
padding-bottom: math.div($item-spacing-v, 2);
1415
}
1516

1617
.radio-group {
1718

18-
padding-bottom: $item-spacing-v / 2;
19+
padding-bottom: math.div($item-spacing-v, 2);
1920

2021
label {
21-
padding: $item-spacing-v / 2 $item-spacing-h / 2;
22+
padding: math.div($item-spacing-v, 2) math.div($item-spacing-h, 2);
2223
}
2324

2425
.label {

0 commit comments

Comments
 (0)