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(material/core): update minimum required sass version and clean up workarounds #23414

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"sass": "^1.34.1",
"sass": "^1.38.0",
"selenium-webdriver": "^3.6.0",
"semver": "^7.3.4",
"send": "^0.17.1",
Expand Down
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-card/card.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'sass:math';
@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.
Expand Down Expand Up @@ -44,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: -(private.private-div($mat-card-default-padding, 2));
margin-top: -(math.div($mat-card-default-padding, 2));
margin-bottom: $mat-card-default-padding;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@use 'sass:map';
@use 'sass:math';
@use '@material/density' as mdc-density;
@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.
Expand Down Expand Up @@ -55,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: private.private-div(mdc-textfield.$height - $height, 2);
$vertical-deduction: math.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,
Expand All @@ -78,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: private.private-div($height, 2);
top: math.div($height, 2);
}

// For the outline appearance, we re-create the active floating label transform. This is
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@use 'sass:map';
@use 'sass:math';
@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.
Expand Down Expand Up @@ -66,8 +66,8 @@ $mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-widt
content: '';
width: 0;
height: 0;
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-left: math.div($mat-form-field-select-arrow-width, 2) solid transparent;
border-right: math.div($mat-form-field-select-arrow-width, 2) solid transparent;
border-top: $mat-form-field-select-arrow-height solid;
position: absolute;
right: 0;
Expand Down
6 changes: 3 additions & 3 deletions src/material-experimental/mdc-select/select.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@use 'sass:math';
@use '@material/menu-surface' as mdc-menu-surface;
@use '@material/list/evolution-mixins' 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;
Expand Down Expand Up @@ -111,7 +111,7 @@ $scale: 0.75 !default;
// 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
private.private-div(variables.$swift-ease-out-duration, 3)
math.div(variables.$swift-ease-out-duration, 3)
variables.$swift-ease-out-timing-function;

._mat-animation-noopable & {
Expand Down Expand Up @@ -143,7 +143,7 @@ $scale: 0.75 !default;
}

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

@include mdc-form-field.core-styles($query: mdc-helpers.$mat-base-styles-query);
Expand Down Expand Up @@ -66,6 +66,6 @@
// 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: private.private-div(map.get(mdc-switch-theme.$light-theme, track-height), 2);
outline-offset: math.div(map.get(mdc-switch-theme.$light-theme, track-height), 2);
}
}
14 changes: 7 additions & 7 deletions src/material/badge/_badge-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
@use 'sass:color';
@use 'sass:map';
@use 'sass:meta';
@use 'sass:math';
@use '../core/theming/theming';
@use '../core/typography/typography';
@use '../core/typography/typography-utils';
@use '../core/style/private';
@use '../../cdk/a11y';

$font-size: 12px;
Expand All @@ -29,13 +29,13 @@ $_badge-structure-emitted: false !default;

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

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

Expand Down Expand Up @@ -68,27 +68,27 @@ $_badge-structure-emitted: false !default;
&.mat-badge-overlap {
&.mat-badge-before {
.mat-badge-content {
left: private.private-div(-$size, 2);
left: math.div(-$size, 2);
}
}

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

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

[dir='rtl'] &.mat-badge-after {
.mat-badge-content {
right: auto;
left: private.private-div(-$size, 2);
left: math.div(-$size, 2);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/material/card/card.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use 'sass:math';
@use '../core/style/variables';
@use '../core/style/elevation';
@use '../core/style/private';
Expand Down Expand Up @@ -59,8 +60,8 @@ $header-size: 40px !default;

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

Expand Down
2 changes: 1 addition & 1 deletion src/material/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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: private.private-div(2, 15) * checkbox-common.$size !default;
$_mark-stroke-size: math.div(2, 15) * checkbox-common.$size !default;


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

.mat-option {
Expand Down Expand Up @@ -78,7 +78,7 @@
}

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

[dir='rtl'] & {
Expand Down
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
@@ -1,3 +1,4 @@
@use 'sass:math';
@use '../../style/checkbox-common';
@use '../../style/private';
@use '../../style/variables';
Expand Down Expand Up @@ -50,20 +51,20 @@ $_checkmark-size: checkbox-common.$size - (2 * $_padding);
}

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

.mat-pseudo-checkbox-checked::after {
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;
top: math.div(checkbox-common.$size, 2) - math.div($_checkmark-size, 4) -
math.div(checkbox-common.$size, 10) - checkbox-common.$border-width;
left: $_padding - checkbox-common.$border-width * 1.5;
width: $_checkmark-size;
height: private.private-div($_checkmark-size - checkbox-common.$border-width, 2);
height: math.div($_checkmark-size - checkbox-common.$border-width, 2);
border-left: checkbox-common.$border-width solid currentColor;
transform: rotate(-45deg);
opacity: 1;
Expand Down
27 changes: 0 additions & 27 deletions src/material/core/style/_private.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
@use 'sass:map';
@use 'sass:math';
@use 'sass:meta';
@use 'sass:list';
@use './elevation';

@mixin private-theme-elevation($zValue, $config, $opacity: elevation.$opacity) {
Expand Down Expand Up @@ -42,27 +39,3 @@
@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};
}
}
7 changes: 2 additions & 5 deletions src/material/core/typography/_typography-utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
@use 'sass:math';
@use 'sass:meta';
@use 'sass:string';
@use '../style/private';


// Utility for fetching a nested value from a typography config.
Expand Down Expand Up @@ -78,10 +77,8 @@
font-family: $font-family;
}
@else {
// Otherwise use the shorthand `font`, because it's the least amount of bytes. Note
// 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 private.private-slash($font-size, $line-height) $font-family;
// Otherwise use the shorthand `font`, because it's the least amount of bytes.
font: $font-weight list.slash($font-size, $line-height) $font-family;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/material/datepicker/calendar-body.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@use '../core/style/private';
@use 'sass:math';
@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: private.private-div(33%, 7) !default;
$calendar-body-label-side-padding: math.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;
Expand Down
4 changes: 2 additions & 2 deletions src/material/datepicker/date-range-input.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@use 'sass:math';
@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
private.private-div(variables.$swift-ease-out-duration, 3)
math.div(variables.$swift-ease-out-duration, 3)
variables.$swift-ease-out-timing-function;
}

Expand Down
4 changes: 2 additions & 2 deletions src/material/form-field/_form-field-fill-theme.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@use 'sass:map';
@use 'sass:math';
@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.
Expand Down Expand Up @@ -55,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: private.private-div(100%, $font-scale) + $fill-dedupe;
width: math.div(100%, $font-scale) + $fill-dedupe;

$fill-dedupe: $fill-dedupe + 0.00001 !global;
}
Expand Down