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

refactor(multiple): fix warnings related to division operator in latest version of Sass #22871

Merged
merged 1 commit into from
Jun 8, 2021
Merged
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
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -15,11 +15,11 @@ http_archive(
# Add sass rules
http_archive(
name = "io_bazel_rules_sass",
sha256 = "c310ba8fe69cce7793954a7f1778b65a86b06690215a504751e12b7df3ab51f8",
strip_prefix = "rules_sass-1.32.13",
sha256 = "80d3e70ab5a8d59494aa9e3a7e4722f9f9a6fe98d1497be6bfa0b9e106b1ea54",
strip_prefix = "rules_sass-1.34.1",
urls = [
"https://github.com/bazelbuild/rules_sass/archive/1.32.13.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_sass/archive/1.32.13.zip",
"https://github.com/bazelbuild/rules_sass/archive/1.34.1.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_sass/archive/1.34.1.zip",
],
)

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -210,7 +210,7 @@
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"sass": "^1.32.13",
"sass": "^1.34.1",
"selenium-webdriver": "^3.6.0",
"semver": "^7.3.4",
"send": "^0.17.1",
3 changes: 2 additions & 1 deletion src/material-experimental/mdc-card/card.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use '@material/card' as mdc-card;
@use '../../material/core/style/private';
@use '../mdc-helpers/mdc-helpers';

// TODO(jelbourn): move header and title-group styles to their own files.
@@ -43,7 +44,7 @@ $mat-card-default-padding: 16px !default;
// When a subtitle is inside of a header, we want to move it up slightly to reduce the space with
// the title, and add a margin bottom to create space underneath the header.
.mat-mdc-card-subtitle {
margin-top: -($mat-card-default-padding / 2);
margin-top: -(private.private-div($mat-card-default-padding, 2));
margin-bottom: $mat-card-default-padding;
}
}
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
@use '@material/textfield' as mdc-textfield;
@use 'sass:map';
@use '../../material/core/theming/theming';
@use '../../material/core/style/private';
@use 'form-field-sizing';

// Mixin that sets the vertical spacing for the infix container of filled form fields.
@@ -54,7 +55,7 @@
// cannot update the spacing to explicit numbers based on the density scale. Instead, we
// determine the height reduction and equally subtract it from the default `top` and `bottom`
// padding that is provided by the Material Design specification.
$vertical-deduction: (mdc-textfield.$height - $height) / 2;
$vertical-deduction: private.private-div(mdc-textfield.$height - $height, 2);
// Map that describes the padding for form-fields with label.
$with-label-padding: (
top: form-field-sizing.$mat-form-field-with-label-input-padding-top - $vertical-deduction,
@@ -77,7 +78,7 @@
// form-field because we do not know what type of form-field control is set up. Hence
// we always use a fixed position for the label. This does not have any implications.
.mat-mdc-form-field .mat-mdc-text-field-wrapper .mdc-floating-label {
top: $height / 2;
top: private.private-div($height, 2);
}

// For the outline appearance, we re-create the active floating label transform. This is
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
@use '../mdc-helpers/mdc-helpers';
@use '../../cdk/a11y';
@use '../../material/core/theming/palette';
@use '../../material/core/style/private';
@use '@material/theme/theme-color' as mdc-theme-color;

// Width of the Material Design form-field select arrow.
@@ -65,8 +66,8 @@ $mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-widt
content: '';
width: 0;
height: 0;
border-left: ($mat-form-field-select-arrow-width / 2) solid transparent;
border-right: ($mat-form-field-select-arrow-width / 2) solid transparent;
border-left: private.private-div($mat-form-field-select-arrow-width, 2) solid transparent;
border-right: private.private-div($mat-form-field-select-arrow-width, 2) solid transparent;
border-top: $mat-form-field-select-arrow-height solid;
position: absolute;
right: 0;
7 changes: 5 additions & 2 deletions src/material-experimental/mdc-select/select.scss
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
@use '@material/list' as mdc-list;
@use '../../material/core/style/variables';
@use '../../material/core/style/vendor-prefixes';
@use '../../material/core/style/private';
@use '../../cdk/a11y';

$mat-select-arrow-size: 5px !default;
@@ -105,7 +106,8 @@ $scale: 0.75 !default;
.mat-mdc-select-placeholder {
// Delay the transition until the label has animated about a third of the way through, in
// order to prevent the placeholder from overlapping for a split second.
transition: color variables.$swift-ease-out-duration variables.$swift-ease-out-duration / 3
transition: color variables.$swift-ease-out-duration
private.private-div(variables.$swift-ease-out-duration, 3)
variables.$swift-ease-out-timing-function;

._mat-animation-noopable & {
@@ -137,7 +139,8 @@ $scale: 0.75 !default;
}

.mdc-floating-label--float-above {
max-width: calc(100% / #{$scale} - #{$mat-select-placeholder-arrow-space / $scale});
$arrow-scale: private.private-div($mat-select-placeholder-arrow-space, $scale);
max-width: calc(100% / #{$scale} - #{$arrow-scale});
}
}
&.mat-form-field-appearance-outline {
5 changes: 3 additions & 2 deletions src/material-experimental/mdc-slide-toggle/slide-toggle.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@use 'sass:map';
@use '@material/switch/deprecated' as mdc-switch with ($deprecated-suffix: '');
@use '@material/form-field' as mdc-form-field;
@use '@material/ripple' as mdc-ripple;
@use 'sass:map';
@use '../mdc-helpers/mdc-helpers';
@use '../../material/core/style/layout-common';
@use '../../material/core/style/private';
@use '../../cdk/a11y';

@include mdc-switch.without-ripple($query: mdc-helpers.$mat-base-styles-query);
@@ -87,7 +88,7 @@
// Usually 1px would be enough, but MDC reduces the opacity on the
// element so we need to make this a bit more prominent.
outline: solid 2px;
outline-offset: mdc-switch.$track-height / 2;
outline-offset: private.private-div(mdc-switch.$track-height, 2);
}
}
}
13 changes: 7 additions & 6 deletions src/material/badge/_badge-theme.scss
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
@use '../core/theming/theming';
@use '../core/typography/typography';
@use '../core/typography/typography-utils';
@use '../core/style/private';
@use '../../cdk/a11y';

$font-size: 12px;
@@ -25,13 +26,13 @@ $large-size: $default-size + 6;

&.mat-badge-above {
.mat-badge-content {
top: -$size / 2;
top: private.private-div(-$size, 2);
}
}

&.mat-badge-below {
.mat-badge-content {
bottom: -$size / 2;
bottom: private.private-div(-$size, 2);
}
}

@@ -64,27 +65,27 @@ $large-size: $default-size + 6;
&.mat-badge-overlap {
&.mat-badge-before {
.mat-badge-content {
left: -$size / 2;
left: private.private-div(-$size, 2);
}
}

[dir='rtl'] &.mat-badge-before {
.mat-badge-content {
left: auto;
right: -$size / 2;
right: private.private-div(-$size, 2);
}
}

&.mat-badge-after {
.mat-badge-content {
right: -$size / 2;
right: private.private-div(-$size, 2);
}
}

[dir='rtl'] &.mat-badge-after {
.mat-badge-content {
right: auto;
left: -$size / 2;
left: private.private-div(-$size, 2);
}
}
}
4 changes: 2 additions & 2 deletions src/material/card/card.scss
Original file line number Diff line number Diff line change
@@ -59,8 +59,8 @@ $header-size: 40px !default;

.mat-card-actions {
@extend %mat-card-section-base;
margin-left: -$padding / 2;
margin-right: -$padding / 2;
margin-left: private.private-div(-$padding, 2);
margin-right: private.private-div(-$padding, 2);
padding: 8px 0;
}

2 changes: 1 addition & 1 deletion src/material/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ $_ripple-radius: 20px;
$_item-spacing: variables.$toggle-padding;

// The width of the line used to draw the checkmark / mixedmark.
$_mark-stroke-size: 2 / 15 * checkbox-common.$size !default;
$_mark-stroke-size: private.private-div(2, 15) * checkbox-common.$size !default;


// Fades in the background of the checkbox when it goes from unchecked -> {checked,indeterminate}.
3 changes: 2 additions & 1 deletion src/material/core/option/option.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@use '../style/menu-common';
@use '../style/vendor-prefixes';
@use '../style/layout-common';
@use '../style/private';
@use '../../../cdk/a11y';

.mat-option {
@@ -77,7 +78,7 @@
}

.mat-option-pseudo-checkbox {
$margin: menu-common.$side-padding / 2;
$margin: private.private-div(menu-common.$side-padding, 2);
margin-right: $margin;

[dir='rtl'] & {
11 changes: 6 additions & 5 deletions src/material/core/selection/pseudo-checkbox/pseudo-checkbox.scss
Original file line number Diff line number Diff line change
@@ -50,19 +50,20 @@ $_checkmark-size: checkbox-common.$size - (2 * $_padding);
}

.mat-pseudo-checkbox-indeterminate::after {
top: (checkbox-common.$size - checkbox-common.$border-width) / 2 - checkbox-common.$border-width;
left: checkbox-common.$border-width / 2;
top: private.private-div(checkbox-common.$size - checkbox-common.$border-width, 2) -
checkbox-common.$border-width;
left: private.private-div(checkbox-common.$border-width, 2);
width: checkbox-common.$size - 6px;
opacity: 1;
border-radius: 2px;
}

.mat-pseudo-checkbox-checked::after {
top: (checkbox-common.$size / 2) - ($_checkmark-size / 4) -
(checkbox-common.$size / 10) - checkbox-common.$border-width;
top: private.private-div(checkbox-common.$size, 2) - private.private-div($_checkmark-size, 4) -
private.private-div(checkbox-common.$size, 10) - checkbox-common.$border-width;
left: $_padding - checkbox-common.$border-width * 1.5;
width: $_checkmark-size;
height: ($_checkmark-size - checkbox-common.$border-width) / 2;
height: private.private-div($_checkmark-size - checkbox-common.$border-width, 2);
border-left: checkbox-common.$border-width solid currentColor;
transform: rotate(-45deg);
opacity: 1;
3 changes: 2 additions & 1 deletion src/material/core/style/_menu-common.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use './private';
@use './list-common';
@use './layout-common';

@@ -63,7 +64,7 @@ $icon-margin: 16px !default;

// Renders a triangle to indicate that the menu item will open a sub-menu.
&::after {
$size: $triangle-height / 2;
$size: private.private-div($triangle-height, 2);

width: 0;
height: 0;
27 changes: 27 additions & 0 deletions src/material/core/style/_private.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@use 'sass:map';
@use 'sass:math';
@use 'sass:meta';
@use 'sass:list';
@use './elevation';

@mixin private-theme-elevation($zValue, $config, $opacity: elevation.$opacity) {
@@ -39,3 +42,27 @@
@content;
}
}

// Private polyfill for the `math.div` function from Sass to be used until we can update the
// minimum required Sass version to 1.34.0 or above.
// TODO(crisbeto): replace with `math.div` eventually.
@function private-div($a, $b) {
@if (meta.function-exists('div', 'math')) {
@return math.div($a, $b);
}
@else {
@return $a / $b;
}
}

// Private polyfill for the `list.slash` function from Sass to be used until we can update the
// minimum required Sass version to 1.34.0 or above.
// TODO(crisbeto): replace with `list.slash` eventually.
@function private-slash($a, $b) {
@if (meta.function-exists('slash', 'list')) {
@return list.slash($a, $b);
}
@else {
@return #{$a}#{' / '}#{$b};
}
}
6 changes: 4 additions & 2 deletions src/material/core/typography/_typography-utils.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@use 'sass:list';
@use 'sass:map';
@use 'sass:meta';
@use 'sass:string';
@use '../style/private';


// Utility for fetching a nested value from a typography config.
@@ -76,9 +78,9 @@
}
@else {
// Otherwise use the shorthand `font`, because it's the least amount of bytes. Note
// that we need to use interpolation for `font-size/line-height` in order to prevent
// that we need to use `list.slash` for `font-size/line-height` in order to prevent
// Sass from dividing the two values.
font: $font-weight #{$font-size}/#{$line-height} $font-family;
font: $font-weight private.private-slash($font-size, $line-height) $font-family;
}
}

5 changes: 4 additions & 1 deletion src/material/datepicker/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -72,7 +72,10 @@ sass_binary(
sass_binary(
name = "calendar_body_scss",
src = "calendar-body.scss",
deps = ["//src/cdk/a11y:a11y_scss_lib"],
deps = [
"//src/cdk/a11y:a11y_scss_lib",
"//src/material/core:core_scss_lib",
],
)

sass_binary(
3 changes: 2 additions & 1 deletion src/material/datepicker/calendar-body.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@use '../core/style/private';
@use '../../cdk/a11y';

$calendar-body-label-padding-start: 5% !default;
// We don't want the label to jump around when we switch between month and year views, so we use
// the same amount of padding regardless of the number of columns. We align the header label with
// the one third mark of the first cell, this was chosen somewhat arbitrarily to make it look
// roughly like the mock. Half way is too far since the cell text is center aligned.
$calendar-body-label-side-padding: 33% / 7 !default;
$calendar-body-label-side-padding: private.private-div(33%, 7) !default;
$calendar-body-cell-min-size: 32px !default;
$calendar-body-cell-content-margin: 5% !default;
$calendar-body-cell-content-border-width: 1px !default;
6 changes: 4 additions & 2 deletions src/material/datepicker/date-range-input.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
@use '../core/style/variables';
@use '../core/style/vendor-prefixes';
@use '../core/style/private';
@use '../../cdk/a11y';

$date-range-input-separator-spacing: 4px;
$date-range-input-part-max-width: calc(50% - #{$date-range-input-separator-spacing});

@mixin _placeholder-transition($property) {
transition: #{$property} variables.$swift-ease-out-duration variables.$swift-ease-out-duration / 3
variables.$swift-ease-out-timing-function;
transition: #{$property} variables.$swift-ease-out-duration
private.private-div(variables.$swift-ease-out-duration, 3)
variables.$swift-ease-out-timing-function;
}

// Host of the date range input.
3 changes: 2 additions & 1 deletion src/material/form-field/_form-field-fill-theme.scss
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
@use '../core/theming/theming';
@use '../core/typography/typography';
@use '../core/typography/typography-utils';
@use '../core/style/private';


// Theme styles that only apply to the fill appearance of the form-field.
@@ -54,7 +55,7 @@ $fill-dedupe: 0;
@mixin _label-floating($font-scale, $infix-padding, $infix-margin-top) {
transform: translateY(-$infix-margin-top - $infix-padding + $fill-dedupe)
scale($font-scale);
width: 100% / $font-scale + $fill-dedupe;
width: private.private-div(100%, $font-scale) + $fill-dedupe;

$fill-dedupe: $fill-dedupe + 0.00001 !global;
}
Loading