Skip to content

Commit 639cdd6

Browse files
committed
refactor(material/chips): implement state layer color using tokens
1 parent 2f992e9 commit 639cdd6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/material/chips/_chips-theme.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@
5858
}
5959
}
6060
}
61-
62-
.mat-mdc-chip-focus-overlay {
63-
background: map.get(map.get($config, foreground), base);
64-
}
6561
}
6662

6763
@mixin typography($config-or-theme) {

src/material/chips/chip.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@use '../core/style/layout-common';
66
@use '../core/focus-indicators/private' as focus-indicators-private;
77
@use '../core/tokens/m2/mdc/chip' as m2-mdc-chip;
8+
@use '../core/tokens/token-utils';
89
@use '@material/theme/custom-properties' as mdc-custom-properties;
910

1011
// The slots for tokens that will be configured in the theme can be emitted with no fallback.
@@ -21,6 +22,13 @@
2122
// Add default values for tokens that aren't outputted by the theming API.
2223
@include mdc-chip-theme.theme(m2-mdc-chip.get-unthemable-tokens());
2324
}
25+
26+
// Add additional slots for the MDC chip tokens, needed in Angular Material.
27+
@include token-utils.use-tokens(m2-mdc-chip.$prefix, $token-slots) {
28+
.mat-mdc-chip-focus-overlay {
29+
@include token-utils.create-token-slot(background, focus-state-layer-color);
30+
}
31+
}
2432
}
2533

2634
// We *should* be able to include these styles through MDC's
@@ -294,4 +302,4 @@
294302
// a separate element, rather than on the focusable element itself.
295303
.mat-mdc-chip-action:focus .mat-mdc-focus-indicator::before {
296304
content: '';
297-
}
305+
}

src/material/core/tokens/m2/mdc/_chip.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ $prefix: (mdc, chip);
135135
// Unused.
136136
focus-outline-color: null,
137137
// Unused.
138-
focus-state-layer-color: null,
139-
// Unused.
140138
focus-state-layer-opacity: null,
141139
// Unused.
142140
hover-label-text-color: null,
@@ -237,13 +235,17 @@ $prefix: (mdc, chip);
237235
$background: theming.get-color-from-palette($palette);
238236
$foreground: theming.get-color-from-palette($palette, default-contrast);
239237

238+
$state-layer: theming.get-color-from-palette(map.get($config, foreground), base);
239+
240240
@return (
241241
// The text color of a disabled chip.
242242
disabled-label-text-color: $foreground,
243243
// The background-color of the chip.
244244
elevated-container-color: $background,
245245
// The background-color of a disabled chip.
246246
elevated-disabled-container-color: $background,
247+
// The chip's state layer color.
248+
focus-state-layer-color: $state-layer,
247249
// The chip text color.
248250
label-text-color: $foreground,
249251
// The icon color of a chip.

0 commit comments

Comments
 (0)