Skip to content

Commit b97dc21

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

File tree

30 files changed

+61
-53
lines changed

30 files changed

+61
-53
lines changed

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

0 commit comments

Comments
 (0)