UNPKG

2.95 kBSCSSView Raw
1//
2// Copyright 2020 Google Inc.
3//
4// Permission is hereby granted, free of charge, to any person obtaining a copy
5// of this software and associated documentation files (the "Software"), to deal
6// in the Software without restriction, including without limitation the rights
7// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8// copies of the Software, and to permit persons to whom the Software is
9// furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20// THE SOFTWARE.
21//
22
23@use '@material/feature-targeting/feature-targeting';
24@use '@material/theme/mixins' as theme-mixins;
25@use '@material/theme/state';
26@use '@material/theme/variables' as theme-variables;
27
28$helper-text-color: rgba(theme-variables.prop-value(on-surface), 0.6) !default;
29$disabled-helper-text-color: rgba(
30 theme-variables.prop-value(on-surface),
31 0.38
32) !default;
33
34@mixin helper-text-color($color-or-map, $query: feature-targeting.all()) {
35 &:not(.mdc-select--disabled) {
36 @include _helper-text-color(
37 state.get-default-state($color-or-map),
38 $query: $query
39 );
40 }
41
42 &.mdc-select--disabled {
43 @include _helper-text-color(
44 state.get-disabled-state($color-or-map),
45 $query: $query
46 );
47 }
48}
49
50@mixin helper-text-validation-color(
51 $color-or-map,
52 $query: feature-targeting.all()
53) {
54 &:not(.mdc-select--disabled) {
55 @include _helper-text-validation-color(
56 state.get-default-state($color-or-map),
57 $query: $query
58 );
59
60 &:not(.mdc-select--focused):hover {
61 @include _helper-text-validation-color(
62 state.get-hover-state($color-or-map),
63 $query: $query
64 );
65 }
66 }
67}
68
69// Private mixins
70
71@mixin _helper-text-color($color, $query: feature-targeting.all()) {
72 $feat-color: feature-targeting.create-target($query, color);
73
74 @if $color {
75 & + .mdc-select-helper-text {
76 @include feature-targeting.targets($feat-color) {
77 @include theme-mixins.property(color, $color);
78 }
79 }
80 }
81}
82
83@mixin _helper-text-validation-color($color, $query: feature-targeting.all()) {
84 $feat-color: feature-targeting.create-target($query, color);
85
86 @if $color {
87 &.mdc-select--invalid + .mdc-select-helper-text--validation-msg {
88 @include feature-targeting.targets($feat-color) {
89 @include theme-mixins.property(color, $color);
90 }
91 }
92 }
93}