Skip to content

Commit e183dd4

Browse files
author
Andrew Seguin
committed
refactor: switch m2 surface colors to system terms
1 parent cf83272 commit e183dd4

File tree

31 files changed

+63
-55
lines changed

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
@@ -15,7 +15,7 @@
1515
// Tokens that can be configured through Angular Material's color theming API.
1616
@function get-color-tokens($theme) {
1717
@return (
18-
autocomplete-background-color: inspection.get-theme-color($theme, background, card)
18+
autocomplete-background-color: inspection.get-theme-color($theme, system, surface)
1919
);
2020
}
2121

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

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

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

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

3535
@return (
36-
button-toggle-background-color: inspection.get-theme-color($theme, background, card),
36+
button-toggle-background-color: inspection.get-theme-color($theme, system, surface),
3737
button-toggle-disabled-selected-state-background-color:
3838
inspection.get-theme-color($theme, background, selected-disabled-button),
3939
button-toggle-disabled-selected-state-text-color:
40-
inspection.get-theme-color($theme, foreground, text),
40+
inspection.get-theme-color($theme, system, on-surface),
4141
button-toggle-disabled-state-background-color:
42-
inspection.get-theme-color($theme, background, card),
42+
inspection.get-theme-color($theme, system, surface),
4343
button-toggle-disabled-state-text-color:
4444
inspection.get-theme-color($theme, foreground, disabled-button),
4545
button-toggle-divider-color: $divider-color,
@@ -58,10 +58,10 @@
5858
button-toggle-legacy-text-color: inspection.get-theme-color($theme, foreground, hint-text),
5959
button-toggle-selected-state-background-color:
6060
inspection.get-theme-color($theme, background, selected-button),
61-
button-toggle-selected-state-text-color: inspection.get-theme-color($theme, foreground, text),
61+
button-toggle-selected-state-text-color: inspection.get-theme-color($theme, system, on-surface),
6262
button-toggle-state-layer-color: sass-utils.safe-color-change(
6363
inspection.get-theme-color($theme, background, focused-button), $alpha: 1),
64-
button-toggle-text-color: inspection.get-theme-color($theme, foreground, text),
64+
button-toggle-text-color: inspection.get-theme-color($theme, system, on-surface),
6565
);
6666
}
6767

src/material/button/_m2-button.scss

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

5555
@return (
56-
button-filled-container-color: inspection.get-theme-color($theme, background, card),
56+
button-filled-container-color: inspection.get-theme-color($theme, system, surface),
5757
button-filled-disabled-container-color:
5858
inspection.get-theme-color($theme, foreground, disabled-button, 0.12),
5959
button-filled-disabled-label-text-color:
@@ -77,7 +77,7 @@
7777
button-outlined-pressed-state-layer-opacity: if($is-dark, 0.24, 0.12),
7878
button-outlined-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
7979
button-outlined-state-layer-color: inspection.get-theme-color($theme, foreground, base),
80-
button-protected-container-color: inspection.get-theme-color($theme, background, card),
80+
button-protected-container-color: inspection.get-theme-color($theme, system, surface),
8181
button-protected-disabled-container-color:
8282
inspection.get-theme-color($theme, foreground, disabled-button, 0.12),
8383
button-protected-disabled-label-text-color:
@@ -99,7 +99,7 @@
9999
button-text-pressed-state-layer-opacity: if($is-dark, 0.24, 0.12),
100100
button-text-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
101101
button-text-state-layer-color: inspection.get-theme-color($theme, foreground, base),
102-
button-tonal-container-color: inspection.get-theme-color($theme, background, card),
102+
button-tonal-container-color: inspection.get-theme-color($theme, system, surface),
103103
button-tonal-disabled-container-color:
104104
inspection.get-theme-color($theme, foreground, disabled-button, 0.12),
105105
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
@@ -33,7 +33,7 @@
3333
$is-dark: inspection.get-theme-type($theme) == dark;
3434

3535
@return (
36-
fab-container-color: inspection.get-theme-color($theme, background, card),
36+
fab-container-color: inspection.get-theme-color($theme, system, surface),
3737
fab-disabled-state-container-color:
3838
inspection.get-theme-color($theme, background, disabled-button, 0.12),
3939
fab-disabled-state-foreground-color:
@@ -44,7 +44,7 @@
4444
fab-hover-state-layer-opacity: if($is-dark, 0.08, 0.04),
4545
fab-pressed-state-layer-opacity: if($is-dark, 0.24, 0.12),
4646
fab-ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
47-
fab-small-container-color: inspection.get-theme-color($theme, background, card),
47+
fab-small-container-color: inspection.get-theme-color($theme, system, surface),
4848
fab-small-disabled-state-container-color:
4949
inspection.get-theme-color($theme, background, disabled-button, 0.12),
5050
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
@@ -17,13 +17,13 @@
1717
// Tokens that can be configured through Angular Material's color theming API.
1818
@function get-color-tokens($theme) {
1919
@return (
20-
card-elevated-container-color: inspection.get-theme-color($theme, background, card),
20+
card-elevated-container-color: inspection.get-theme-color($theme, system, surface),
2121
card-elevated-container-elevation: elevation.get-box-shadow(1),
22-
card-outlined-container-color: inspection.get-theme-color($theme, background, card),
22+
card-outlined-container-color: inspection.get-theme-color($theme, system, surface),
2323
card-outlined-container-elevation: elevation.get-box-shadow(0),
2424
card-outlined-outline-color: rgba(inspection.get-theme-color($theme, foreground, base), 0.12),
2525
card-subtitle-text-color: inspection.get-theme-color($theme, foreground, secondary-text),
26-
card-filled-container-color: inspection.get-theme-color($theme, background, card),
26+
card-filled-container-color: inspection.get-theme-color($theme, system, surface),
2727
card-filled-container-elevation: elevation.get-box-shadow(0)
2828
);
2929
}

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
@@ -41,15 +41,15 @@
4141
$background: null;
4242
$state-layer-color: inspection.get-theme-color($theme, foreground, base);
4343
$state-layer-opacity: 0.12; // 0.12 is a common value in Material Design for opacity.
44-
$surface: inspection.get-theme-color($theme, background, card);
44+
$surface: inspection.get-theme-color($theme, system, surface);
4545

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

52-
$surface: inspection.get-theme-color($theme, background, card);
52+
$surface: inspection.get-theme-color($theme, system, surface);
5353
$background: if(
5454
meta.type-of($state-layer-color) == color and meta.type-of($surface) == color,
5555
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
@@ -14,7 +14,7 @@
1414
@function get-color-tokens($theme) {
1515
$tokens: (
1616
app-background-color: inspection.get-theme-color($theme, background, background),
17-
app-text-color: inspection.get-theme-color($theme, foreground, text),
17+
app-text-color: inspection.get-theme-color($theme, system, on-surface),
1818
);
1919

2020
@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
@@ -11,7 +11,7 @@
1111
// Tokens that can be configured through Angular Material's color theming API.
1212
@function get-color-tokens($theme) {
1313
@return (
14-
optgroup-label-text-color: inspection.get-theme-color($theme, foreground, text),
14+
optgroup-label-text-color: inspection.get-theme-color($theme, system, on-surface),
1515
);
1616
}
1717

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

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

1717
@return (
1818
option-selected-state-label-text-color: inspection.get-theme-color($theme, $palette-name),
19-
option-label-text-color: inspection.get-theme-color($theme, foreground, text),
19+
option-label-text-color: inspection.get-theme-color($theme, system, on-surface),
2020
option-hover-state-layer-color: $active-state-layer-color,
2121
option-focus-state-layer-color: $active-state-layer-color,
2222
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
@@ -39,7 +39,7 @@ $private-default-overlap-color: #a8dab5;
3939
// Tokens that can be configured through Angular Material's color theming API.
4040
@function get-color-tokens($theme) {
4141
$inactive-icon-color: inspection.get-theme-color($theme, foreground, icon);
42-
$text-color: inspection.get-theme-color($theme, foreground, text);
42+
$text-color: inspection.get-theme-color($theme, system, on-surface);
4343
$secondary-text-color: inspection.get-theme-color($theme, foreground, secondary-text);
4444
$disabled-text-color: inspection.get-theme-color($theme, foreground, disabled-text);
4545
$divider-color: inspection.get-theme-color($theme, foreground, divider);
@@ -92,7 +92,7 @@ $private-default-overlap-color: #a8dab5;
9292
datepicker-range-input-disabled-state-text-color: $disabled-text-color,
9393

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

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
@@ -17,14 +17,14 @@
1717
// Tokens that can be configured through Angular Material's color theming API.
1818
@function get-color-tokens($theme) {
1919
@return (
20-
expansion-container-background-color: inspection.get-theme-color($theme, background, card),
21-
expansion-container-text-color: inspection.get-theme-color($theme, foreground, text),
20+
expansion-container-background-color: inspection.get-theme-color($theme, system, surface),
21+
expansion-container-text-color: inspection.get-theme-color($theme, system, on-surface),
2222
expansion-actions-divider-color: inspection.get-theme-color($theme, foreground, divider),
2323
expansion-header-hover-state-layer-color: inspection.get-theme-color($theme, background, hover),
2424
expansion-header-focus-state-layer-color: inspection.get-theme-color($theme, background, hover),
2525
expansion-header-disabled-state-text-color: inspection.get-theme-color(
2626
$theme, foreground, disabled-button),
27-
expansion-header-text-color: inspection.get-theme-color($theme, foreground, text),
27+
expansion-header-text-color: inspection.get-theme-color($theme, system, on-surface),
2828
expansion-header-description-color:
2929
inspection.get-theme-color($theme, foreground, secondary-text),
3030
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
@@ -29,7 +29,7 @@
2929
@function get-color-tokens($theme) {
3030
$is-dark: inspection.get-theme-type($theme) == dark;
3131
$foreground-base: inspection.get-theme-color($theme, foreground, base);
32-
$foreground-text: inspection.get-theme-color($theme, foreground, text);
32+
$foreground-text: inspection.get-theme-color($theme, system, on-surface);
3333
$foreground-secondary-text: inspection.get-theme-color($theme, foreground, secondary-text);
3434
$foreground-hint-text: inspection.get-theme-color($theme, foreground, hint-text);
3535
$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
@@ -28,14 +28,14 @@
2828
$is-dark: inspection.get-theme-type($theme) == dark;
2929
$active-state-layer-color: inspection.get-theme-color($theme, foreground, base,
3030
if($is-dark, 0.08, 0.04));
31-
$text-color: inspection.get-theme-color($theme, foreground, text);
31+
$text-color: inspection.get-theme-color($theme, system, on-surface);
3232

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

src/material/paginator/_m2-paginator.scss

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

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

src/material/radio/_m2-radio.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
radio-disabled-label-color: inspection.get-theme-color($theme, foreground, disabled-text),
3131
radio-disabled-selected-icon-color: inspection.get-theme-color($theme, foreground, icon, 1),
3232
radio-disabled-unselected-icon-color: inspection.get-theme-color($theme, foreground, icon, 1),
33-
radio-label-text-color: inspection.get-theme-color($theme, foreground, text),
33+
radio-label-text-color: inspection.get-theme-color($theme, system, on-surface),
3434
radio-ripple-color: inspection.get-theme-color($theme, foreground, base),
3535
radio-selected-focus-icon-color: $palette-color,
3636
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
@@ -22,15 +22,15 @@
2222
$is-dark: inspection.get-theme-type($theme) == dark;
2323
$scrim-opacity: 0.6;
2424
$scrim-color: sass-utils.safe-color-change(
25-
inspection.get-theme-color($theme, background, card), $alpha: $scrim-opacity);
25+
inspection.get-theme-color($theme, system, surface), $alpha: $scrim-opacity);
2626
$fallback-scrim-color: if($is-dark, rgba(#fff, $scrim-opacity), rgba(#000, $scrim-opacity));
2727

2828
@return (
2929
sidenav-container-divider-color: inspection.get-theme-color($theme, foreground, divider),
30-
sidenav-container-background-color: inspection.get-theme-color($theme, background, dialog),
31-
sidenav-container-text-color: inspection.get-theme-color($theme, foreground, text),
30+
sidenav-container-background-color: inspection.get-theme-color($theme, system, surface),
31+
sidenav-container-text-color: inspection.get-theme-color($theme, system, on-surface),
3232
sidenav-content-background-color: inspection.get-theme-color($theme, background, background),
33-
sidenav-content-text-color: inspection.get-theme-color($theme, foreground, text),
33+
sidenav-content-text-color: inspection.get-theme-color($theme, system, on-surface),
3434

3535
// We use invert() here to have the darken the background color expected to be used.
3636
// 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
@@ -86,7 +86,7 @@
8686
slide-toggle-disabled-unselected-track-color: $on-surface,
8787
slide-toggle-handle-elevation-shadow: elevation.get-box-shadow(1),
8888
slide-toggle-handle-surface-color: #fff,
89-
slide-toggle-label-text-color: inspection.get-theme-color($theme, foreground, text),
89+
slide-toggle-label-text-color: inspection.get-theme-color($theme, system, on-surface),
9090
slide-toggle-selected-icon-color: $icon-color,
9191
slide-toggle-unselected-hover-handle-color: $on-surface-state-content,
9292
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
@@ -15,7 +15,7 @@
1515
// Tokens that can be configured through Angular Material's color theming API.
1616
@function get-color-tokens($theme) {
1717
$is-dark: inspection.get-theme-type($theme) == dark;
18-
$surface: inspection.get-theme-color($theme, background, card);
18+
$surface: inspection.get-theme-color($theme, system, surface);
1919

2020
@return (
2121
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
@@ -12,7 +12,7 @@
1212

1313
// Tokens that can be configured through Angular Material's color theming API.
1414
@function get-color-tokens($theme) {
15-
$table-background: inspection.get-theme-color($theme, background, card);
15+
$table-background: inspection.get-theme-color($theme, system, surface);
1616
$text-color: inspection.get-theme-color($theme, foreground, secondary-text);
1717
$arrow-color: null;
1818

0 commit comments

Comments
 (0)