forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 9
/
_select-theme.scss
120 lines (98 loc) · 3.75 KB
/
_select-theme.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@use '@material/theme/theme-color' as mdc-theme-color;
@use '@material/menu-surface' as mdc-menu-surface;
@use '@material/list/evolution-mixins' as mdc-list;
@use '@material/typography' as mdc-typography;
@use '@material/density' as mdc-density;
@use '@material/textfield' as mdc-textfield;
@use '../core/theming/theming';
@use '../core/typography/typography';
@use '../core/mdc-helpers/mdc-helpers';
// Gets the color to use for some text that is highlighted while a select has focus.
@function _get-mdc-focused-text-color($palette) {
@return rgba(mdc-theme-color.prop-value($palette), 0.87);
}
@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);
@include mdc-helpers.using-mdc-theme($config) {
$disabled-color: rgba(mdc-theme-color.prop-value(on-surface), 0.38);
@include mdc-menu-surface.core-styles(mdc-helpers.$mdc-theme-styles-query);
@include mdc-list.without-ripple(mdc-helpers.$mdc-theme-styles-query);
.mat-mdc-select-value {
color: rgba(mdc-theme-color.prop-value(on-surface), 0.87);
}
.mat-mdc-select-placeholder {
color: rgba(mdc-theme-color.prop-value(on-surface), 0.6);
}
.mat-mdc-select-disabled .mat-mdc-select-value {
color: $disabled-color;
}
.mat-mdc-select-arrow {
color: rgba(mdc-theme-color.prop-value(on-surface), 0.54);
}
.mat-mdc-form-field {
&.mat-focused {
&.mat-primary .mat-mdc-select-arrow {
color: _get-mdc-focused-text-color(primary);
}
&.mat-accent .mat-mdc-select-arrow {
color: _get-mdc-focused-text-color(secondary);
}
&.mat-warn .mat-mdc-select-arrow {
color: _get-mdc-focused-text-color(error);
}
}
.mat-mdc-select.mat-mdc-select-invalid .mat-mdc-select-arrow {
color: _get-mdc-focused-text-color(error);
}
.mat-mdc-select.mat-mdc-select-disabled .mat-mdc-select-arrow {
color: $disabled-color;
}
}
}
}
@mixin typography($config-or-theme) {
$config: typography.private-typography-to-2018-config(
theming.get-typography-config($config-or-theme));
@include mdc-helpers.using-mdc-typography($config) {
@include mdc-menu-surface.core-styles(mdc-helpers.$mdc-typography-styles-query);
.mat-mdc-select-panel {
@include mdc-list.list-base(mdc-helpers.$mdc-typography-styles-query);
}
.mat-mdc-select {
@include mdc-typography.typography(body1, $query: mdc-helpers.$mdc-typography-styles-query);
}
}
}
@mixin density($config-or-theme) {
$density-scale: theming.get-density-config($config-or-theme);
// Density is clamped at -5 here, because MDC's form field throws an error for anything lower.
$form-field-height: mdc-density.prop-value(
$density-config: mdc-textfield.$density-config,
$density-scale: theming.clamp-density($density-scale, -5),
$property-name: height,
);
// On lower densities the filled form field hides its label which causes the label to
// be misaligned. Remove the additional offset that was added because of the label.
@if ($form-field-height < mdc-textfield.$minimum-height-for-filled-label) {
.mat-form-field-appearance-fill .mat-mdc-select-arrow-wrapper {
transform: none;
}
}
}
@mixin theme($theme-or-color-config) {
$theme: theming.private-legacy-get-theme($theme-or-color-config);
@include theming.private-check-duplicate-theme-styles($theme, 'mat-select') {
$color: theming.get-color-config($theme);
$density: theming.get-density-config($theme);
$typography: theming.get-typography-config($theme);
@if $color != null {
@include color($color);
}
@if $density != null {
@include density($density);
}
@if $typography != null {
@include typography($typography);
}
}
}