Skip to content

Commit 04d8e02

Browse files
authored
refactor: switch m2 surface colors to system terms (#31175)
1 parent 734c2ec commit 04d8e02

31 files changed

+63
-55
lines changed

src/material-experimental/popover-edit/_popover-edit-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77

88
@mixin color($theme) {
9-
$background-color: mat.get-theme-color($theme, background, 'card');
9+
$background-color: mat.get-theme-color($theme, system, surface);
1010

1111
// TODO: these structural styles don't belong in the `color` part of a theme.
1212
// We should figure out a better place for them.

src/material/autocomplete/_m2-autocomplete.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Tokens that can be configured through Angular Material's color theming API.
1414
@function get-color-tokens($theme) {
1515
@return (
16-
autocomplete-background-color: inspection.get-theme-color($theme, background, card)
16+
autocomplete-background-color: inspection.get-theme-color($theme, system, surface)
1717
);
1818
}
1919

src/material/bottom-sheet/_m2-bottom-sheet.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// Tokens that can be configured through Angular Material's color theming API.
1313
@function get-color-tokens($theme) {
1414
@return (
15-
bottom-sheet-container-text-color: inspection.get-theme-color($theme, foreground, text),
16-
bottom-sheet-container-background-color: inspection.get-theme-color($theme, background, dialog),
15+
bottom-sheet-container-text-color: inspection.get-theme-color($theme, system, on-surface),
16+
bottom-sheet-container-background-color: inspection.get-theme-color($theme, system, surface),
1717
);
1818
}
1919

src/material/button-toggle/_m2-button-toggle.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@
2828
$divider-color: if(
2929
meta.type-of($theme-divider-color) == color,
3030
theming.private-rgba-to-hex(
31-
$theme-divider-color, inspection.get-theme-color($theme, background, card)),
31+
$theme-divider-color, inspection.get-theme-color($theme, system, surface)),
3232
$theme-divider-color);
3333

3434
@return (
35-
button-toggle-background-color: inspection.get-theme-color($theme, background, card),
35+
button-toggle-background-color: inspection.get-theme-color($theme, system, surface),
3636
button-toggle-disabled-selected-state-background-color:
3737
inspection.get-theme-color($theme, background, selected-disabled-button),
3838
button-toggle-disabled-selected-state-text-color:
39-
inspection.get-theme-color($theme, foreground, text),
39+
inspection.get-theme-color($theme, system, on-surface),
4040
button-toggle-disabled-state-background-color:
41-
inspection.get-theme-color($theme, background, card),
41+
inspection.get-theme-color($theme, system, surface),
4242
button-toggle-disabled-state-text-color:
4343
inspection.get-theme-color($theme, foreground, disabled-button),
4444
button-toggle-divider-color: $divider-color,
@@ -57,10 +57,10 @@
5757
button-toggle-legacy-text-color: inspection.get-theme-color($theme, foreground, hint-text),
5858
button-toggle-selected-state-background-color:
5959
inspection.get-theme-color($theme, background, selected-button),
60-
button-toggle-selected-state-text-color: inspection.get-theme-color($theme, foreground, text),
60+
button-toggle-selected-state-text-color: inspection.get-theme-color($theme, system, on-surface),
6161
button-toggle-state-layer-color: sass-utils.safe-color-change(
6262
inspection.get-theme-color($theme, background, focused-button), $alpha: 1),
63-
button-toggle-text-color: inspection.get-theme-color($theme, foreground, text),
63+
button-toggle-text-color: inspection.get-theme-color($theme, system, on-surface),
6464
);
6565
}
6666

src/material/button/_m2-button.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
);
5353

5454
@return (
55-
button-filled-container-color: inspection.get-theme-color($theme, background, card),
55+
button-filled-container-color: inspection.get-theme-color($theme, system, surface),
5656
button-filled-disabled-container-color:
5757
inspection.get-theme-color($theme, foreground, disabled-button, 0.12),
5858
button-filled-disabled-label-text-color:
@@ -76,7 +76,7 @@
7676
button-outlined-pressed-state-layer-opacity: if($is-dark, 0.24, 0.12),
7777
button-outlined-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
7878
button-outlined-state-layer-color: inspection.get-theme-color($theme, foreground, base),
79-
button-protected-container-color: inspection.get-theme-color($theme, background, card),
79+
button-protected-container-color: inspection.get-theme-color($theme, system, surface),
8080
button-protected-disabled-container-color:
8181
inspection.get-theme-color($theme, foreground, disabled-button, 0.12),
8282
button-protected-disabled-label-text-color:
@@ -98,7 +98,7 @@
9898
button-text-pressed-state-layer-opacity: if($is-dark, 0.24, 0.12),
9999
button-text-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
100100
button-text-state-layer-color: inspection.get-theme-color($theme, foreground, base),
101-
button-tonal-container-color: inspection.get-theme-color($theme, background, card),
101+
button-tonal-container-color: inspection.get-theme-color($theme, system, surface),
102102
button-tonal-disabled-container-color:
103103
inspection.get-theme-color($theme, foreground, disabled-button, 0.12),
104104
button-tonal-disabled-label-text-color:

src/material/button/_m2-fab.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
$is-dark: inspection.get-theme-type($theme) == dark;
3333

3434
@return (
35-
fab-container-color: inspection.get-theme-color($theme, background, card),
35+
fab-container-color: inspection.get-theme-color($theme, system, surface),
3636
fab-disabled-state-container-color:
3737
inspection.get-theme-color($theme, background, disabled-button, 0.12),
3838
fab-disabled-state-foreground-color:
@@ -43,7 +43,7 @@
4343
fab-hover-state-layer-opacity: if($is-dark, 0.08, 0.04),
4444
fab-pressed-state-layer-opacity: if($is-dark, 0.24, 0.12),
4545
fab-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
46-
fab-small-container-color: inspection.get-theme-color($theme, background, card),
46+
fab-small-container-color: inspection.get-theme-color($theme, system, surface),
4747
fab-small-disabled-state-container-color:
4848
inspection.get-theme-color($theme, background, disabled-button, 0.12),
4949
fab-small-disabled-state-foreground-color:

src/material/card/_m2-card.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
// Tokens that can be configured through Angular Material's color theming API.
1616
@function get-color-tokens($theme) {
1717
@return (
18-
card-elevated-container-color: inspection.get-theme-color($theme, background, card),
18+
card-elevated-container-color: inspection.get-theme-color($theme, system, surface),
1919
card-elevated-container-elevation: elevation.get-box-shadow(1),
20-
card-outlined-container-color: inspection.get-theme-color($theme, background, card),
20+
card-outlined-container-color: inspection.get-theme-color($theme, system, surface),
2121
card-outlined-container-elevation: elevation.get-box-shadow(0),
2222
card-outlined-outline-color: rgba(inspection.get-theme-color($theme, foreground, base), 0.12),
2323
card-subtitle-text-color: inspection.get-theme-color($theme, foreground, secondary-text),
24-
card-filled-container-color: inspection.get-theme-color($theme, background, card),
24+
card-filled-container-color: inspection.get-theme-color($theme, system, surface),
2525
card-filled-container-elevation: elevation.get-box-shadow(0)
2626
);
2727
}

src/material/checkbox/_m2-checkbox.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
$tokens: (
4949
checkbox-disabled-label-color: inspection.get-theme-color($theme, foreground, disabled-text),
50-
checkbox-label-text-color: inspection.get-theme-color($theme, foreground, text),
50+
checkbox-label-text-color: inspection.get-theme-color($theme, system, on-surface),
5151
checkbox-disabled-selected-icon-color: $disabled-color,
5252
checkbox-disabled-unselected-icon-color: $disabled-color,
5353
checkbox-selected-checkmark-color: $selected-checkmark-color,

src/material/chips/_m2-chip.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939
$background: null;
4040
$state-layer-color: inspection.get-theme-color($theme, foreground, base);
4141
$state-layer-opacity: 0.12; // 0.12 is a common value in Material Design for opacity.
42-
$surface: inspection.get-theme-color($theme, background, card);
42+
$surface: inspection.get-theme-color($theme, system, surface);
4343

4444
@if $palette-name == null {
4545
$is-dark: inspection.get-theme-type($theme) == dark;
4646
$grey-50: map.get(m2-palette.$grey-palette, 50);
4747
$grey-900: map.get(m2-palette.$grey-palette, 900);
4848
$foreground: if($is-dark, $grey-50, $grey-900);
4949

50-
$surface: inspection.get-theme-color($theme, background, card);
50+
$surface: inspection.get-theme-color($theme, system, surface);
5151
$background: if(
5252
meta.type-of($state-layer-color) == color and meta.type-of($surface) == color,
5353
color.mix($state-layer-color, $surface, 12%),

src/material/core/_m2-app.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@function get-color-tokens($theme) {
1313
$tokens: (
1414
app-background-color: inspection.get-theme-color($theme, background, background),
15-
app-text-color: inspection.get-theme-color($theme, foreground, text),
15+
app-text-color: inspection.get-theme-color($theme, system, on-surface),
1616
);
1717

1818
@for $zValue from 0 through 24 {

src/material/core/m2/_theming.scss

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@
120120
warn: if($warn != null, $warn, define-palette(palette.$red-palette)),
121121
is-dark: false,
122122
foreground: palette.$light-theme-foreground-palette,
123-
background: palette.$light-theme-background-palette
123+
background: palette.$light-theme-background-palette,
124+
system: (
125+
surface: white,
126+
on-surface: rgba(black, 0.87),
127+
),
124128
);
125129
}
126130

@@ -133,7 +137,11 @@
133137
warn: if($warn != null, $warn, define-palette(palette.$red-palette)),
134138
is-dark: true,
135139
foreground: palette.$dark-theme-foreground-palette,
136-
background: palette.$dark-theme-background-palette
140+
background: palette.$dark-theme-background-palette,
141+
system: (
142+
surface: map.get(palette.$grey-palette, 800),
143+
on-surface: white,
144+
),
137145
);
138146
}
139147

src/material/core/option/_m2-optgroup.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Tokens that can be configured through Angular Material's color theming API.
1010
@function get-color-tokens($theme) {
1111
@return (
12-
optgroup-label-text-color: inspection.get-theme-color($theme, foreground, text),
12+
optgroup-label-text-color: inspection.get-theme-color($theme, system, on-surface),
1313
);
1414
}
1515

src/material/core/option/_m2-option.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@return (
1616
option-selected-state-label-text-color: inspection.get-theme-color($theme, $palette-name),
17-
option-label-text-color: inspection.get-theme-color($theme, foreground, text),
17+
option-label-text-color: inspection.get-theme-color($theme, system, on-surface),
1818
option-hover-state-layer-color: $active-state-layer-color,
1919
option-focus-state-layer-color: $active-state-layer-color,
2020
option-selected-state-layer-color: $active-state-layer-color,

src/material/datepicker/_m2-datepicker.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $private-default-overlap-color: #a8dab5;
3838
// Tokens that can be configured through Angular Material's color theming API.
3939
@function get-color-tokens($theme) {
4040
$inactive-icon-color: inspection.get-theme-color($theme, foreground, icon);
41-
$text-color: inspection.get-theme-color($theme, foreground, text);
41+
$text-color: inspection.get-theme-color($theme, system, on-surface);
4242
$secondary-text-color: inspection.get-theme-color($theme, foreground, secondary-text);
4343
$disabled-text-color: inspection.get-theme-color($theme, foreground, disabled-text);
4444
$divider-color: inspection.get-theme-color($theme, foreground, divider);
@@ -91,7 +91,7 @@ $private-default-overlap-color: #a8dab5;
9191
datepicker-range-input-disabled-state-text-color: $disabled-text-color,
9292

9393
datepicker-calendar-container-background-color:
94-
inspection.get-theme-color($theme, background, card),
94+
inspection.get-theme-color($theme, system, surface),
9595
datepicker-calendar-container-text-color: $text-color,
9696
));
9797
}

src/material/dialog/_m2-dialog.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
);
3636

3737
@return (
38-
dialog-container-color: inspection.get-theme-color($theme, background, dialog),
38+
dialog-container-color: inspection.get-theme-color($theme, system, surface),
3939
dialog-subhead-color: sass-utils.safe-color-change($text-base, $alpha: 0.87),
4040
dialog-supporting-text-color: sass-utils.safe-color-change($text-base, $alpha: 0.6),
4141
);

src/material/expansion/_m2-expansion.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
// Tokens that can be configured through Angular Material's color theming API.
1616
@function get-color-tokens($theme) {
1717
@return (
18-
expansion-container-background-color: inspection.get-theme-color($theme, background, card),
19-
expansion-container-text-color: inspection.get-theme-color($theme, foreground, text),
18+
expansion-container-background-color: inspection.get-theme-color($theme, system, surface),
19+
expansion-container-text-color: inspection.get-theme-color($theme, system, on-surface),
2020
expansion-actions-divider-color: inspection.get-theme-color($theme, foreground, divider),
2121
expansion-header-hover-state-layer-color: inspection.get-theme-color($theme, background, hover),
2222
expansion-header-focus-state-layer-color: inspection.get-theme-color($theme, background, hover),
2323
expansion-header-disabled-state-text-color: inspection.get-theme-color(
2424
$theme, foreground, disabled-button),
25-
expansion-header-text-color: inspection.get-theme-color($theme, foreground, text),
25+
expansion-header-text-color: inspection.get-theme-color($theme, system, on-surface),
2626
expansion-header-description-color:
2727
inspection.get-theme-color($theme, foreground, secondary-text),
2828
expansion-header-indicator-color:

src/material/form-field/_m2-form-field.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// Tokens that can be configured through Angular Material's color theming API.
2525
@function get-color-tokens($theme) {
2626
$is-dark: inspection.get-theme-type($theme) == dark;
27-
$surface: inspection.get-theme-color($theme, background, card);
27+
$surface: inspection.get-theme-color($theme, system, surface);
2828
$warn-color: inspection.get-theme-color($theme, warn);
2929
$color-tokens: private-get-color-palette-color-tokens($theme, primary);
3030
$on-surface: if($is-dark, #fff, #000);

src/material/list/_m2-list.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@function get-color-tokens($theme) {
2929
$is-dark: inspection.get-theme-type($theme) == dark;
3030
$foreground-base: inspection.get-theme-color($theme, foreground, base);
31-
$foreground-text: inspection.get-theme-color($theme, foreground, text);
31+
$foreground-text: inspection.get-theme-color($theme, system, on-surface);
3232
$foreground-secondary-text: inspection.get-theme-color($theme, foreground, secondary-text);
3333
$foreground-hint-text: inspection.get-theme-color($theme, foreground, hint-text);
3434
$text-icon-on-background: sass-utils.safe-color-change(

src/material/menu/_m2-menu.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
$is-dark: inspection.get-theme-type($theme) == dark;
2727
$active-state-layer-color: inspection.get-theme-color($theme, foreground, base,
2828
if($is-dark, 0.08, 0.04));
29-
$text-color: inspection.get-theme-color($theme, foreground, text);
29+
$text-color: inspection.get-theme-color($theme, system, on-surface);
3030

3131
@return (
3232
menu-item-label-text-color: $text-color,
3333
menu-item-icon-color: $text-color,
3434
menu-item-hover-state-layer-color: $active-state-layer-color,
3535
menu-item-focus-state-layer-color: $active-state-layer-color,
36-
menu-container-color: inspection.get-theme-color($theme, background, card),
36+
menu-container-color: inspection.get-theme-color($theme, system, surface),
3737
menu-divider-color: inspection.get-theme-color($theme, foreground, divider),
3838
);
3939
}

src/material/paginator/_m2-paginator.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
@return (
1818
paginator-container-text-color: sass-utils.safe-color-change($foreground-base, $alpha: 0.87),
19-
paginator-container-background-color: inspection.get-theme-color($theme, background, card),
19+
paginator-container-background-color: inspection.get-theme-color($theme, system, surface),
2020
paginator-enabled-icon-color: sass-utils.safe-color-change($foreground-base, $alpha: 0.54),
2121
paginator-disabled-icon-color: sass-utils.safe-color-change($foreground-base, $alpha: 0.12),
2222
);

src/material/radio/_m2-radio.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
radio-disabled-label-color: inspection.get-theme-color($theme, foreground, disabled-text),
2929
radio-disabled-selected-icon-color: inspection.get-theme-color($theme, foreground, icon, 1),
3030
radio-disabled-unselected-icon-color: inspection.get-theme-color($theme, foreground, icon, 1),
31-
radio-label-text-color: inspection.get-theme-color($theme, foreground, text),
31+
radio-label-text-color: inspection.get-theme-color($theme, system, on-surface),
3232
radio-ripple-color: inspection.get-theme-color($theme, foreground, base),
3333
radio-selected-focus-icon-color: $palette-color,
3434
radio-selected-hover-icon-color: $palette-color,

src/material/select/_m2-select.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
inspection.get-theme-color($theme, foreground, divider, 1));
2929

3030
@return (
31-
select-panel-background-color: inspection.get-theme-color($theme, background, card),
31+
select-panel-background-color: inspection.get-theme-color($theme, system, surface),
3232
select-enabled-trigger-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.87),
3333
select-disabled-trigger-text-color:
3434
sass-utils.safe-color-change($disabled-text-color-base, $alpha: 0.38),

src/material/sidenav/_m2-sidenav.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
$is-dark: inspection.get-theme-type($theme) == dark;
2222
$scrim-opacity: 0.6;
2323
$scrim-color: sass-utils.safe-color-change(
24-
inspection.get-theme-color($theme, background, card), $alpha: $scrim-opacity);
24+
inspection.get-theme-color($theme, system, surface), $alpha: $scrim-opacity);
2525
$fallback-scrim-color: if($is-dark, rgba(#fff, $scrim-opacity), rgba(#000, $scrim-opacity));
2626

2727
@return (
2828
sidenav-container-divider-color: inspection.get-theme-color($theme, foreground, divider),
29-
sidenav-container-background-color: inspection.get-theme-color($theme, background, dialog),
30-
sidenav-container-text-color: inspection.get-theme-color($theme, foreground, text),
29+
sidenav-container-background-color: inspection.get-theme-color($theme, system, surface),
30+
sidenav-container-text-color: inspection.get-theme-color($theme, system, on-surface),
3131
sidenav-content-background-color: inspection.get-theme-color($theme, background, background),
32-
sidenav-content-text-color: inspection.get-theme-color($theme, foreground, text),
32+
sidenav-content-text-color: inspection.get-theme-color($theme, system, on-surface),
3333

3434
// We use invert() here to have the darken the background color expected to be used.
3535
// If the background is light, we use a dark backdrop. If the background is dark, we

src/material/slide-toggle/_m2-slide-toggle.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
slide-toggle-disabled-unselected-track-color: $on-surface,
8585
slide-toggle-handle-elevation-shadow: elevation.get-box-shadow(1),
8686
slide-toggle-handle-surface-color: #fff,
87-
slide-toggle-label-text-color: inspection.get-theme-color($theme, foreground, text),
87+
slide-toggle-label-text-color: inspection.get-theme-color($theme, system, on-surface),
8888
slide-toggle-selected-icon-color: $icon-color,
8989
slide-toggle-unselected-hover-handle-color: $on-surface-state-content,
9090
slide-toggle-unselected-focus-handle-color: $on-surface-state-content,

src/material/snack-bar/_m2-snack-bar.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Tokens that can be configured through Angular Material's color theming API.
1414
@function get-color-tokens($theme) {
1515
$is-dark: inspection.get-theme-type($theme) == dark;
16-
$surface: inspection.get-theme-color($theme, background, card);
16+
$surface: inspection.get-theme-color($theme, system, surface);
1717

1818
@return (
1919
snack-bar-container-color: if(

src/material/sort/_m2-sort.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Tokens that can be configured through Angular Material's color theming API.
1010
@function get-color-tokens($theme) {
1111
@return (
12-
sort-arrow-color: inspection.get-theme-color($theme, foreground, text),
12+
sort-arrow-color: inspection.get-theme-color($theme, system, on-surface),
1313
);
1414
}
1515

0 commit comments

Comments
 (0)