Skip to content

Commit 58764af

Browse files
authored
fix(material/chips): Tokenize the hover & focus overlays (#28497)
This will give us the flexibility we need to implement M3 chips
1 parent 965ff55 commit 58764af

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

src/material-experimental/theming/_custom-tokens.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@
227227
$alpha: 0.12,
228228
),
229229
focus-outline-color: map.get($systems, md-sys-color, on-surface-variant),
230+
hover-state-layer-color: map.get($systems, md-sys-color, on-surface-variant),
231+
hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity),
232+
with-avatar-disabled-avatar-opacity: _hardcode(0.38, $exclude-hardcoded),
230233
),
231234
), (
232235
// Color variants:

src/material/chips/chip.scss

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@
2626
@include token-utils.use-tokens(tokens-mdc-chip.$prefix, $mdc-chip-token-slots) {
2727
.mat-mdc-chip-focus-overlay {
2828
@include token-utils.create-token-slot(background, focus-state-layer-color);
29-
@include token-utils.create-token-slot(opacity, focus-state-layer-opacity);
29+
30+
.mat-mdc-chip:hover & {
31+
@include token-utils.create-token-slot(background, hover-state-layer-color);
32+
@include token-utils.create-token-slot(opacity, hover-state-layer-opacity);
33+
}
34+
35+
.mat-mdc-chip.cdk-focused & {
36+
@include token-utils.create-token-slot(background, focus-state-layer-color);
37+
@include token-utils.create-token-slot(opacity, focus-state-layer-opacity);
38+
}
39+
}
40+
41+
.mdc-evolution-chip--disabled:not(.mdc-evolution-chip--selected) .mat-mdc-chip-avatar {
42+
@include token-utils.create-token-slot(opacity, with-avatar-disabled-avatar-opacity);
3043
}
3144
}
3245

@@ -175,14 +188,6 @@
175188
.mat-mdc-basic-chip & {
176189
display: none;
177190
}
178-
179-
.mat-mdc-chip:hover & {
180-
opacity: 0.04;
181-
}
182-
183-
.mat-mdc-chip.cdk-focused & {
184-
opacity: 0.12;
185-
}
186191
}
187192

188193
// The ripple container should match the bounds of the entire chip.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ $prefix: (mdc, chip);
4747
disabled-outline-color: transparent,
4848
// The chip's border color when focused.
4949
focus-outline-color: transparent,
50+
// The opacity of the chip's state overlay when hovered.
51+
hover-state-layer-opacity: 0.04,
52+
// Not used by MDC.
53+
with-avatar-disabled-avatar-opacity: 1,
5054
// Not used by MDC.
5155
disabled-label-text-opacity: null,
5256
// Not used by MDC.
@@ -64,8 +68,6 @@ $prefix: (mdc, chip);
6468
// Our chips do not have a border.
6569
flat-unselected-outline-width: null,
6670
// Not used by MDC.
67-
with-avatar-disabled-avatar-opacity: null,
68-
// Not used by MDC.
6971
with-icon-disabled-icon-opacity: null,
7072
// Not used by MDC.
7173
with-leading-icon-disabled-leading-icon-opacity: null,
@@ -142,10 +144,6 @@ $prefix: (mdc, chip);
142144
// Unused.
143145
hover-label-text-color: null,
144146
// Unused.
145-
hover-state-layer-color: null,
146-
// Unused.
147-
hover-state-layer-opacity: null,
148-
// Unused.
149147
pressed-label-text-color: null,
150148
// Unused.
151149
pressed-state-layer-color: null,
@@ -269,6 +267,8 @@ $prefix: (mdc, chip);
269267
elevated-disabled-container-color: $background,
270268
// The color of the focus state layer.
271269
focus-state-layer-color: $state-layer-color,
270+
// The color of the hover state layer.
271+
hover-state-layer-color: $state-layer-color,
272272
// The opacity of the focus state layer.
273273
focus-state-layer-opacity: $state-layer-opacity,
274274
// The chip text color.

0 commit comments

Comments
 (0)