Skip to content

Commit fca43aa

Browse files
authored
fix(material/select): styles for m3 (#28492)
* fix(material/select): m3 native select invalid arrow color * fix(material/select): m3 option background color * fix(material/select): m3 box-shadow * fixup! fix(material/select): m3 box-shadow
1 parent 8fab892 commit fca43aa

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,8 @@
10121012
map.get($systems, md-sys-color, on-surface), $alpha: 0.38),
10131013
focused-arrow-color: map.get($systems, md-sys-color, primary),
10141014
invalid-arrow-color: map.get($systems, md-sys-color, error),
1015+
container-elevation-shadow:
1016+
_hardcode(mdc-elevation.elevation-box-shadow(2), $exclude-hardcoded),
10151017
)
10161018
), (
10171019
// Color variants:

src/material/core/tokens/m2/mat/_select.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
@use '../../token-utils';
22
@use '../../../theming/inspection';
33
@use '../../../style/sass-utils';
4+
@use '@material/elevation/elevation-theme' as mdc-elevation;
45

56
// The prefix used to generate the fully qualified name for tokens in this file.
67
$prefix: (mat, select);
78

89
// Tokens that can't be configured through Angular Material's current theming API,
910
// but may be in a future version of the theming API.
1011
@function get-unthemable-tokens() {
11-
@return ();
12+
@return (
13+
container-elevation-shadow: mdc-elevation.elevation-box-shadow(8),
14+
);
1215
}
1316

1417
// Tokens that can be configured through Angular Material's color theming API.

src/material/select/_select-theme.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
@if inspection.get-theme-version($theme) == 1 {
1616
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
1717
}
18-
@else {}
18+
@else {
19+
@include sass-utils.current-selector-or-root() {
20+
$mat-tokens: tokens-mat-select.get-unthemable-tokens();
21+
@include token-utils.create-token-values(tokens-mat-select.$prefix, $mat-tokens);
22+
}
23+
}
1924
}
2025

2126
/// Outputs color theme styles for the mat-select.

src/material/select/select.scss

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@use 'sass:math';
22
@use '@angular/cdk';
33
@use '@material/typography/typography' as mdc-typography;
4-
@use '../core/style/elevation';
54
@use '../core/style/vendor-prefixes';
65
@use '../core/style/variables';
76
@use '../core/tokens/token-utils';
@@ -32,6 +31,11 @@ $scale: 0.75 !default;
3231
@include token-utils.create-token-slot(letter-spacing, trigger-text-tracking);
3332
}
3433
}
34+
@include token-utils.use-tokens(tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
35+
div.mat-mdc-select-panel {
36+
@include token-utils.create-token-slot(box-shadow, container-elevation-shadow);
37+
}
38+
}
3539

3640
.mat-mdc-select-disabled {
3741
@include token-utils.use-tokens(
@@ -83,6 +87,13 @@ $scale: 0.75 !default;
8387
}
8488
}
8589

90+
.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-invalid .mat-mdc-select-arrow,
91+
.mat-form-field-invalid:not(.mat-form-field-disabled) .mat-mdc-form-field-infix::after {
92+
@include token-utils.use-tokens(tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
93+
@include token-utils.create-token-slot(color, invalid-arrow-color);
94+
}
95+
}
96+
8697
.mat-mdc-select-arrow {
8798
width: $mat-select-arrow-size * 2;
8899
height: $mat-select-arrow-size;
@@ -96,10 +107,6 @@ $scale: 0.75 !default;
96107
@include token-utils.create-token-slot(color, focused-arrow-color);
97108
}
98109

99-
.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-invalid & {
100-
@include token-utils.create-token-slot(color, invalid-arrow-color);
101-
}
102-
103110
.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-disabled & {
104111
@include token-utils.create-token-slot(color, disabled-arrow-color);
105112
}
@@ -128,7 +135,6 @@ $scale: 0.75 !default;
128135
// DOM for the Gmat versions to work. We need to bump up the specificity here
129136
// so that it's higher than MDC's styles.
130137
div.mat-mdc-select-panel {
131-
@include elevation.elevation(8);
132138
width: 100%; // Ensures that the panel matches the overlay width.
133139
max-height: $mat-select-panel-max-height;
134140
outline: 0;
@@ -160,6 +166,10 @@ div.mat-mdc-select-panel {
160166
border-bottom-right-radius: 0;
161167
transform-origin: bottom center;
162168
}
169+
170+
.mat-mdc-option {
171+
--mdc-list-list-item-container-color: var(--mat-select-panel-background-color);
172+
}
163173
}
164174

165175
.mat-mdc-select-placeholder {

0 commit comments

Comments
 (0)