Skip to content

Commit 029136e

Browse files
authored
refactor(material/core): resolve circular dependencies (#21110)
Hopefully the last set of code changes for the Sass module system migration. * Combines `theming/_theming.scss` and `theming/_private.scss`, because they had a circular dependency and since `theming.scss` could be considered a public API, we can't move the utilities out into a shared file. * Changes the `angular-material-density` mixin to include density mixins individually, instead of going through `angular-material-theme`. The previous approach had transient circular dependencies that will turn into hard errors once we switch to the Sass module system. The new approach is in line with what we're doing already inside `angular-material-typography`. * Switches a few MDC function calls to go through `@use` instead of `@import`. For some reason Sass was having a hard time finding the old ones after the files are migrated to the module system. * Passes a variable as a parameter to `mat-mdc-private-dialog-structure-overrides`, instead of expecting it to be available as a global variable. This seems like an oversight. * Fixes several places where mixins were being imported transitevely, rather than explicitly. This will be an error with the Sass module system.
1 parent 26c7e54 commit 029136e

File tree

67 files changed

+220
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+220
-237
lines changed

src/dev-app/theme.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ $dark-theme: mat-dark-theme((
8686
// The classes are applied conditionally based on the selected density in the dev-app layout
8787
// component.
8888
$density-scales: (-1, -2, minimum, maximum);
89-
@each $density in$density-scales {
89+
@each $density in $density-scales {
9090
.demo-density-#{$density} {
9191
@include angular-material-density($density);
9292
@include angular-material-mdc-density($density);

src/material-experimental/column-resize/_column-resize.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import '../../material/core/style/variables';
22
@import '../../material/core/style/vendor-prefixes';
3-
@import '../../material/core/theming/private';
43
@import '../../material/core/theming/palette';
54
@import '../../material/core/theming/theming';
65

src/material-experimental/mdc-button/_button-theme.scss

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import '@material/fab/mixins.import';
44
@import '@material/ripple/mixins.import';
55
@import '@material/icon-button/mixins.import';
6+
@import '@material/theme/mixins.import';
67
@import '../../material/core/ripple/ripple';
78
@import '../mdc-helpers/mdc-helpers';
89

src/material-experimental/mdc-core/_core.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '../../material/core/theming/private';
1+
@import '../../material/core/theming/theming';
22
@import './option/option-theme';
33
@import './option/optgroup-theme';
44

src/material-experimental/mdc-core/option/_optgroup-theme.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
@import '@material/list/mixins.import';
22
@import '@material/list/variables.import';
33
@import '@material/theme/functions.import';
4+
@import '@material/theme/mixins.import';
45
@import '../../mdc-helpers/mdc-helpers';
5-
@import '../../../material/core/theming/private';
6+
@import '../../../material/core/theming/theming';
67

78
@mixin mat-mdc-optgroup-color($config-or-theme) {
89
$config: mat-get-color-config($config-or-theme);

src/material-experimental/mdc-core/option/_option-theme.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
@import '@material/list/mixins.import';
22
@import '@material/list/variables.import';
33
@import '@material/theme/functions.import';
4+
@import '@material/theme/mixins.import';
45
@import '../../mdc-helpers/mdc-helpers';
5-
@import '../../../material/core/theming/private';
6+
@import '../../../material/core/theming/theming';
67

78
@mixin mat-mdc-option-color($config-or-theme) {
89
$config: mat-get-color-config($config-or-theme);

src/material-experimental/mdc-dialog/_mdc-dialog-structure-overrides.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Mixin that can be included to override the default MDC dialog styles to fit
22
// our needs. See individual comments for context on why certain styles need to be modified.
3-
@mixin mat-mdc-private-dialog-structure-overrides() {
3+
@mixin mat-mdc-private-dialog-structure-overrides($content-max-height) {
44
// MDC dialog sets max-height and max-width on the `mdc-dialog__surface` element. This
55
// element is the parent of the portal outlet. This means that the actual user-content
66
// is scrollable, but as per Material Design specification, only the dialog content
@@ -10,7 +10,7 @@
1010
// an explicit max-height for the content element, so that the content is scrollable. This
1111
// matches the behavior from the non-MDC dialog and is backwards compatible.
1212
.mat-mdc-dialog-content {
13-
max-height: $mat-dialog-content-max-height;
13+
max-height: $content-max-height;
1414
}
1515

1616
.mat-mdc-dialog-container {

src/material-experimental/mdc-dialog/dialog.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $mat-dialog-content-max-height: 65vh !default;
1212
$mat-dialog-button-horizontal-margin: 8px !default;
1313

1414
@include mdc-dialog-core-styles($query: $mat-base-styles-query);
15-
@include mat-mdc-private-dialog-structure-overrides();
15+
@include mat-mdc-private-dialog-structure-overrides($mat-dialog-content-max-height);
1616

1717
// The dialog container is focusable. We remove the default outline shown in browsers.
1818
.mat-mdc-dialog-container {

src/material-experimental/mdc-form-field/_form-field-density.scss

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
@import '@material/density/functions.import';
1+
@use '@material/density';
22
@import '@material/textfield/variables.import';
3+
@import '../../material/core/theming/theming';
34
@import 'form-field-sizing';
45

56
// Mixin that sets the vertical spacing for the infix container of filled form fields.
@@ -38,7 +39,7 @@
3839
@mixin mat-mdc-private-form-field-density($config-or-theme) {
3940
$density-scale: mat-get-density-config($config-or-theme);
4041
// Height of the form field that is based on the current density scale.
41-
$height: mdc-density-prop-value(
42+
$height: density.prop-value(
4243
$density-config: $mdc-text-field-density-config,
4344
$density-scale: $density-scale,
4445
$property-name: height,

src/material-experimental/mdc-form-field/_form-field-subscript.scss

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '@material/theme/mixins.import';
2+
@import '@material/textfield/variables.import';
13
@import 'form-field-sizing';
24
@import '../mdc-helpers/mdc-helpers';
35

src/material-experimental/mdc-helpers/_mdc-helpers.scss

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
@import '@material/typography/variables.import';
99
@import '../../material/core/style/layout-common';
1010
@import '../../material/core/theming/theming';
11-
@import '../../material/core/theming/private';
1211
@import '../../material/core/typography/typography';
1312

1413
// A set of standard queries to use with MDC's queryable mixins.

src/material-experimental/mdc-list/_list-theme.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '@material/density/functions.import';
1+
@use '@material/density';
22
@import '@material/list/variables.import';
33
@import '@material/list/mixins.import';
44

@@ -34,7 +34,7 @@
3434

3535
@mixin mat-mdc-list-density($config-or-theme) {
3636
$density-scale: mat-get-density-config($config-or-theme);
37-
$height: mdc-density-prop-value(
37+
$height: density.prop-value(
3838
$density-config: $mdc-list-single-line-density-config,
3939
$density-scale: $density-scale,
4040
$property-name: height,

src/material-experimental/mdc-menu/_menu-theme.scss

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import '@material/list/mixins.import';
44
@import '@material/list/variables.import';
55
@import '@material/theme/functions.import';
6+
@import '@material/theme/mixins.import';
67
@import '../mdc-helpers/mdc-helpers';
78

89
@mixin mat-mdc-menu-color($config-or-theme) {

src/material-experimental/mdc-menu/menu.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use '@material/density';
12
@import '@material/menu-surface/mixins.import';
23
@import '@material/list/mixins.import';
34
@import '@material/list/variables.import';
@@ -29,7 +30,7 @@
2930
}
3031

3132
.mat-mdc-menu-item {
32-
$height: mdc-density-prop-value(
33+
$height: density.prop-value(
3334
$density-config: $mdc-list-single-line-density-config,
3435
$density-scale: $mdc-list-single-line-density-scale,
3536
$property-name: height,

src/material-experimental/mdc-paginator/_paginator-theme.scss

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
@import '@material/theme/variables.import';
2-
@import '@material/typography/variables.import';
3-
@import '../../material/core/theming/private';
2+
@import '@material/typography/mixins.import';
3+
@import '../../material/core/theming/theming';
44
@import '../../material/core/density/private/compatibility';
5+
@import '../mdc-helpers/mdc-helpers';
56
@import './paginator-variables';
67

78
@mixin mat-mdc-paginator-color($config-or-theme) {

src/material-experimental/mdc-tabs/_tabs-theme.scss

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import '@material/theme/functions.import';
2+
@import '@material/theme/mixins.import';
23
@import '@material/tab-indicator/mixins.import';
34
@import '@material/tab/mixins.import';
45
@import '@material/tab/variables.import';

src/material-experimental/mdc-theming/_all-theme.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@import '../mdc-input/input-theme';
2020
@import '../mdc-form-field/form-field-theme';
2121
@import '../../material/core/core';
22-
@import '../../material/core/theming/private';
22+
@import '../../material/core/theming/theming';
2323

2424
@mixin angular-material-mdc-theme($theme-or-color-config) {
2525
$dedupe-key: 'angular-material-mdc-theme';

src/material-experimental/selection/_selection.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '../../material/core/theming/private';
1+
@import '../../material/core/theming/theming';
22

33
@mixin mat-selection-theme($theme-or-color-config) {
44
$theme: mat-private-legacy-get-theme($theme-or-color-config);

src/material/autocomplete/_autocomplete-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import '../core/style/private';
22
@import '../core/theming/theming';
3-
@import '../core/theming/private';
43

54
@mixin mat-autocomplete-color($config-or-theme) {
65
$config: mat-get-color-config($config-or-theme);

src/material/badge/_badge-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// no style sheet support for directives.
44
@import '../core/theming/palette';
55
@import '../core/theming/theming';
6-
@import '../core/theming/private';
76
@import '../core/typography/typography-utils';
87
@import '../../cdk/a11y/a11y';
98

src/material/bottom-sheet/_bottom-sheet-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@import '../core/typography/typography-utils';
33
@import '../core/theming/palette';
44
@import '../core/theming/theming';
5-
@import '../core/theming/private';
65

76
@mixin mat-bottom-sheet-color($config-or-theme) {
87
$config: mat-get-color-config($config-or-theme);

src/material/button-toggle/_button-toggle-theme.scss

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@import '../core/style/private';
33
@import '../core/theming/palette';
44
@import '../core/theming/theming';
5-
@import '../core/theming/private';
65
@import '../core/typography/typography-utils';
76
@import '../core/density/private/compatibility';
87
@import './button-toggle-variables';
@@ -92,7 +91,7 @@
9291
}
9392
}
9493

95-
@mixin _mat-button-toggle-density($config-or-theme) {
94+
@mixin mat-button-toggle-density($config-or-theme) {
9695
$density-scale: mat-get-density-config($config-or-theme);
9796
$standard-height: mat-private-density-prop-value(
9897
$mat-button-toggle-standard-density-config, $density-scale, height);
@@ -115,7 +114,7 @@
115114
@include mat-button-toggle-color($color);
116115
}
117116
@if $density != null {
118-
@include _mat-button-toggle-density($density);
117+
@include mat-button-toggle-density($density);
119118
}
120119
@if $typography != null {
121120
@include mat-button-toggle-typography($typography);

src/material/button/_button-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@import '../core/theming/theming';
22
@import '../core/style/private';
33
@import '../core/typography/typography-utils';
4-
@import '../core/theming/private';
54

65
$_mat-button-ripple-opacity: 0.1;
76

src/material/card/_card-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import '../core/theming/palette';
22
@import '../core/theming/theming';
3-
@import '../core/theming/private';
43
@import '../core/style/private';
54
@import '../core/typography/typography-utils';
65

src/material/checkbox/_checkbox-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@import '../core/theming/theming';
2-
@import '../core/theming/private';
32
@import '../core/typography/typography-utils';
43

54

src/material/chips/_chips-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@import '../core/style/private';
22
@import '../core/theming/palette';
33
@import '../core/theming/theming';
4-
@import '../core/theming/private';
54
@import '../core/typography/typography-utils';
65

76
$mat-chip-remove-font-size: 18px;

src/material/core/color/_all-color.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@import '../theming/all-theme';
2-
@import '../theming/private';
2+
@import '../theming/theming';
33

44
// Includes all of the color styles.
55
@mixin angular-material-color($config-or-theme) {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
@import '../../theming/private';
1+
@import '../../theming/theming';
2+
@import '../../../expansion/expansion-theme';
3+
@import '../../../stepper/stepper-theme';
4+
@import '../../../toolbar/toolbar-theme';
5+
@import '../../../tree/tree-theme';
6+
@import '../../../paginator/paginator-theme';
7+
@import '../../../form-field/form-field-theme';
8+
@import '../../../button-toggle/button-toggle-theme';
29

310
// Includes all of the density styles.
411
@mixin angular-material-density($config-or-theme) {
@@ -11,9 +18,17 @@
1118
@error 'No density configuration specified.';
1219
}
1320

14-
@include angular-material-theme((
15-
color: null,
16-
typography: null,
17-
density: $config,
18-
));
21+
// TODO: COMP-309: Do not use individual mixins. Instead, use the all-theme mixin and only
22+
// specify a `density` config while setting `color` and `typography` to `null`. This is currently
23+
// not possible as it would introduce a circular dependency for density because the `mat-core`
24+
// mixin that is transitively loaded by the `all-theme` file, imports `all-density` which
25+
// would then load `all-theme` again. This ultimately results a circular dependency.
26+
27+
@include mat-expansion-panel-density($config);
28+
@include mat-stepper-density($config);
29+
@include mat-toolbar-density($config);
30+
@include mat-tree-density($config);
31+
@include mat-paginator-density($config);
32+
@include mat-form-field-density($config);
33+
@include mat-button-toggle-density($config);
1934
}

src/material/core/focus-indicators/_focus-indicators.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@import '../theming/theming';
2-
@import '../theming/private';
32
@import '../style/layout-common';
43

54
/// Mixin that turns on strong focus indicators.

src/material/core/option/_optgroup-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import '../theming/palette';
22
@import '../theming/theming';
3-
@import '../theming/private';
43
@import '../typography/typography-utils';
54

65
@mixin mat-optgroup-color($config-or-theme) {

src/material/core/option/_option-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import '../theming/palette';
22
@import '../theming/theming';
3-
@import '../theming/private';
43
@import '../typography/typography-utils';
54

65
@mixin mat-option-color($config-or-theme) {

src/material/core/ripple/_ripple.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@import '../theming/theming';
2-
@import '../theming/private';
32
@import '../../../cdk/a11y/a11y';
43

54
$mat-ripple-color-opacity: 0.1;

src/material/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@import '../../theming/theming';
2-
@import '../../theming/private';
32

43
@mixin mat-pseudo-checkbox-color($config-or-theme) {
54
$config: mat-get-color-config($config-or-theme);

src/material/core/theming/_all-theme.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@import '../../tree/tree-theme';
3535
@import '../../snack-bar/snack-bar-theme';
3636
@import '../../form-field/form-field-theme';
37-
@import './private';
37+
@import './theming';
3838

3939
// Create a theme.
4040
@mixin angular-material-theme($theme-or-color-config) {

0 commit comments

Comments
 (0)