Skip to content

Commit

Permalink
perf: better compatibility with deprecated divide method
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreytse committed Oct 21, 2024
1 parent 6b376ec commit ed51549
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _sass/misc/article-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
.post-menu-content {
ul {
border-left: 1px solid #e9ecef;
$indent: math.div($base-font-size, 4);
$indent: divide($base-font-size, 4);
$active-bgcolor: #ecebec;

@for $i from 2 to 7 {
Expand Down
13 changes: 13 additions & 0 deletions _sass/yat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Recommendation: math.div($header-height, 1.5) or calc($header-height / 1.5)
// More info and automated migrator: https://sass-lang.com/d/slash-div
@use 'sass:math';
@use 'sass:meta';

// Define defaults for each variable.

Expand Down Expand Up @@ -63,6 +64,18 @@ $on-laptop: 800px !default;
font-size: $base-font-size * $ratio;
}

// Better compatibility for divisions.
//
// Deprecation Warning: Using / for division outside of calc() is deprecated
// and will be removed in Dart Sass 2.0.0."
@function divide($dividend, $divisor: 1) {
@if meta.function-exists('div', 'math') {
@return math.div($dividend, $divisor);
} @else {
@return ($dividend / $divisor);
}
}

// Import partials.
@import
"yat/base",
Expand Down

0 comments on commit ed51549

Please sign in to comment.