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

Use "sass:math" for percentage function #15524

Open
wants to merge 1 commit into
base: develop
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
4 changes: 3 additions & 1 deletion scss/components/_button-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/// @group button-group
////

@use "sass:math";

/// Margin for button groups.
/// @type Number
$buttongroup-margin: 1rem !default;
Expand Down Expand Up @@ -131,7 +133,7 @@ $buttongroup-radius-on-each: true !default;
&:first-child:nth-last-child(#{$i}) {
&, &:first-child:nth-last-child(#{$i}) ~ #{$selector} {
display: inline-block;
width: calc(#{percentage(divide(1, $i))} - #{$spacing});
width: calc(#{math.percentage(divide(1, $i))} - #{$spacing});
margin-#{$global-right}: $spacing;

&:last-child {
Expand Down
4 changes: 3 additions & 1 deletion scss/grid/_flex-grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/// @group flex-grid
////

@use "sass:math";

/// Creates a container for a flex grid row.
///
/// @param {Keyword|List} $behavior [null]
Expand Down Expand Up @@ -103,7 +105,7 @@
flex-wrap: wrap;

> #{$selector} {
$pct: percentage(divide(1, $n));
$pct: math.percentage(divide(1, $n));

flex: 0 0 $pct;
max-width: $pct;
Expand Down
4 changes: 3 additions & 1 deletion scss/grid/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/// @group grid
////

@use "sass:math";

/// Sizes child elements so that `$n` number of items appear on each row.
///
/// @param {Number} $n - Number of elements to display per row.
Expand All @@ -21,7 +23,7 @@
) {
& > #{$selector} {
float: $global-left;
width: percentage(divide(1, $n));
width: math.percentage(divide(1, $n));

// If a $gutter value is passed
@if($gutter) {
Expand Down
4 changes: 3 additions & 1 deletion scss/grid/_position.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/// @group grid
////

@use "sass:math";

/// Reposition a column.
///
/// @param {Number|Keyword} $position - It can be:
Expand All @@ -32,7 +34,7 @@

// Push/pull
@else if type-of($position) == 'number' {
$offset: percentage(divide($position, $grid-column-count));
$offset: math.percentage(divide($position, $grid-column-count));

position: relative;
#{$global-left}: $offset;
Expand Down
2 changes: 1 addition & 1 deletion scss/util/_math.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
}
}

@return percentage(divide($parsed-nominator, $parsed-denominator));
@return math.percentage(divide($parsed-nominator, $parsed-denominator));
}

/// Divide the given `$divident` by the given `$divisor`.
Expand Down
3 changes: 2 additions & 1 deletion scss/util/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
////

@use "sass:color";
@use "sass:math";

// Patch to fix issue #12080
$-zf-bp-value: null;
Expand Down Expand Up @@ -197,7 +198,7 @@ $-zf-bp-value: null;
@for $i from 2 through $max {
&:nth-last-child(#{$i}):first-child,
&:nth-last-child(#{$i}):first-child ~ #{$elem} {
width: percentage(divide(1, $i));
width: math.percentage(divide(1, $i));
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion scss/xy-grid/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/// @group xy-grid
////

@use "sass:math";

/// Sizes child elements so that `$n` number of items appear on each row.
///
/// @param {Number} $n - Number of elements to display per row.
Expand All @@ -28,7 +30,7 @@
$vertical: false,
$output: (base size gutters)
) {
$size: percentage(divide(1, $n));
$size: math.percentage(divide(1, $n));

& > #{$selector} {
@include xy-cell($size, $gutter-output, $gutters, $gutter-type, $gutter-position, $breakpoint, $vertical, $output);
Expand Down