Skip to content

Commit b84f011

Browse files
committed
refactor(sass): migrate to @use modules and extract vars/mixins
Updates theme to modern Sass module system to resolve build errors caused by deprecated @import behavior and missing variable/mixin scope.
1 parent aab502e commit b84f011

6 files changed

Lines changed: 47 additions & 45 deletions

File tree

_sass/_base.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
@use "sass:color";
2+
3+
@use "mixins" as *;
4+
@use "variables" as *;
5+
6+
17
/**
28
* Reset some basic elements
39
*/
@@ -9,7 +15,6 @@ dl, dd, ol, ul, figure {
915
}
1016

1117

12-
1318
/**
1419
* Basic styling
1520
*/
@@ -160,7 +165,7 @@ pre {
160165
margin-left: auto;
161166
padding-right: $spacing-unit;
162167
padding-left: $spacing-unit;
163-
@extend %clearfix;
168+
@extend %clearfix !optional;
164169

165170
@include media-query($on-laptop) {
166171
max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit}));

_sass/_layout.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
@use "variables" as *;
2+
@use "mixins" as *;
3+
14
/**
25
* Site header
36
*/
@@ -111,7 +114,7 @@
111114
font-size: 15px;
112115
color: $grey-color;
113116
margin-left: calc($spacing-unit / 2);
114-
@extend %clearfix;
117+
@extend %clearfix !optional;
115118
}
116119

117120
.footer-col {

_sass/_mixins.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@mixin media-query($device) {
2+
@media screen and (max-width: $device) {
3+
@content;
4+
}
5+
}
6+

_sass/_syntax-highlighting.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
*/
44
.highlight {
55
background: #fff;
6-
@extend %vertical-rhythm;
6+
@extend %vertical-rhythm !optional;
7+
78

89
.c { color: #998; font-style: italic } // Comment
910
.err { color: #a61717; background-color: #e3d2d2 } // Error

_sass/_variables.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@use "sass:color";
2+
3+
$base-font-family: Helvetica, Arial, sans-serif;
4+
$base-font-size: 16px;
5+
$small-font-size: $base-font-size * 0.875;
6+
$base-line-height: 1.5;
7+
8+
$spacing-unit: 30px;
9+
10+
$text-color: #111;
11+
$background-color: #fdfdfd;
12+
$brand-color: #2a7ae2;
13+
14+
$grey-color: #828282;
15+
$grey-color-light: color.scale($grey-color, $lightness: 40%);
16+
$grey-color-dark: color.scale($grey-color, $lightness: -25%);
17+
18+
$content-width: 800px;
19+
20+
$on-palm: 600px;
21+
$on-laptop: 800px;
22+

css/main.scss

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,12 @@
33
sitemap_exclude: true
44
---
55

6+
67
@charset "utf-8";
78
@use "sass:color";
9+
@use "variables" as *;
10+
@use "mixins" as *;
11+
@use "base" as *;
12+
@use "layout" as *;
13+
@use "syntax-highlighting" as *;
814

9-
// Variables
10-
$base-font-family: Helvetica, Arial, sans-serif;
11-
$base-font-size: 16px;
12-
$small-font-size: $base-font-size * 0.875;
13-
$base-line-height: 1.5;
14-
15-
$spacing-unit: 30px;
16-
17-
$text-color: #111;
18-
$background-color: #fdfdfd;
19-
$brand-color: #2a7ae2;
20-
21-
$grey-color: #828282;
22-
$grey-color-light: color.scale($grey-color, $lightness: 40%);
23-
$grey-color-dark: color.scale($grey-color, $lightness: -25%);
24-
25-
// Width of the content area
26-
$content-width: 800px;
27-
28-
$on-palm: 600px;
29-
$on-laptop: 800px;
30-
31-
// Media query mixin
32-
// Usage:
33-
// @include media-query($on-palm) {
34-
// .wrapper {
35-
// padding-right: $spacing-unit / 2;
36-
// padding-left: $spacing-unit / 2;
37-
// }
38-
// }
39-
@mixin media-query($device) {
40-
@media screen and (max-width: $device) {
41-
@content;
42-
}
43-
}
44-
45-
// Import partials from `sass_dir` (defaults to `_sass`)
46-
@import
47-
"base",
48-
"layout",
49-
"syntax-highlighting";

0 commit comments

Comments
 (0)