Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 fix scss deprecated warnings with math.div #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scss/private/typefaces/_multiplier.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// ----------
// Gets typeface multiplier
// ==========

@use 'sass:math';

@function _ty-get-typeface-multiplier(
$typeface,
$typefaces
Expand All @@ -14,7 +17,7 @@
}

@if $_font-size-ratio {
@return 1 / $_font-size-ratio;
@return math.div(1, $_font-size-ratio);
} @else {
@return 1;
}
Expand Down
13 changes: 8 additions & 5 deletions scss/private/utils/_converters.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// _ty-strip-unit
// ==============

@use 'sass:math';

@function _ty-strip-unit($num) {
@return $num / ($num * 0 + 1);
@return math.div($num, ($num * 0 + 1));
}


Expand All @@ -11,7 +14,7 @@
@if unit($font-size) != 'px' {
@error "_ty-to-percentage() only accepts pixel sizes"
} @else {
@return $font-size / 16px * 100%;
@return math.div($font-size, 16px) * 100%;
}
}

Expand All @@ -22,13 +25,13 @@
@if not $ref-size {
@error "$ref-size must be present for px -> em conversion";
} @else {
@return _ty-strip-unit($font-size) / _ty-strip-unit($ref-size) * 1em;
@return math.div(_ty-strip-unit($font-size), _ty-strip-unit($ref-size)) * 1em;
}
}

@else if unit($font-size) == 'em' {
@if $ref-size {
@return _ty-strip-unit($font-size) / _ty-strip-unit($ref-size) * 1em;
@return math.div(_ty-strip-unit($font-size), _ty-strip-unit($ref-size)) * 1em;
} @else {
@return _ty-strip-unit($font-size) * 1em;
}
Expand All @@ -50,7 +53,7 @@
@if not $ref-size {
@error "$ref-size must be present for px -> rem conversion";
} @else {
@return _ty-strip-unit($font-size) / _ty-strip-unit($ref-size) * 1rem;
@return math.div(_ty-strip-unit($font-size), _ty-strip-unit($ref-size)) * 1rem;
}
}

Expand Down
4 changes: 3 additions & 1 deletion scss/public/rhythm/_rhythm.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use 'sass:math';

@import 'baseline';
////
/// @param {Map} $typefaces [$typefaces]
Expand Down Expand Up @@ -39,7 +41,7 @@
$_rhythm-multiplier: 1;
$_return: 1;
@if $typeface {
$_rhythm-multiplier: 1 / _ty-get-typeface-multiplier($typeface, $typefaces);
$_rhythm-multiplier: math.div(1, _ty-get-typeface-multiplier($typeface, $typefaces));
}

@if unit($current-font-size) == 'px' {
Expand Down