UNPKG

3.88 kBSCSSView Raw
1//
2// Copyright 2018 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// stylelint-disable selector-class-pattern --
24// Selector '.mdc-*' should only be used in this project.
25
26@use '@material/animation/animation';
27@use '@material/animation/variables';
28@use '@material/theme/theme';
29@use '@material/typography/typography';
30@use '@material/feature-targeting/feature-targeting';
31
32// Public mixins
33
34@mixin helper-text-core-styles($query: feature-targeting.all()) {
35 $feat-structure: feature-targeting.create-target($query, structure);
36 $feat-animation: feature-targeting.create-target($query, animation);
37
38 // postcss-bem-linter: define text-field-helper-text
39
40 .mdc-text-field-helper-text {
41 @include typography.typography(caption, $query: $query);
42 @include typography.text-baseline($top: 16px, $query: $query);
43
44 @include feature-targeting.targets($feat-structure) {
45 margin: 0;
46 opacity: 0;
47 will-change: opacity;
48 }
49
50 @include feature-targeting.targets($feat-animation) {
51 transition: animation.standard(opacity, 150ms);
52 }
53 }
54
55 .mdc-text-field-helper-text--persistent {
56 @include feature-targeting.targets($feat-animation) {
57 transition: none;
58 }
59
60 @include feature-targeting.targets($feat-structure) {
61 opacity: 1;
62 will-change: initial;
63 }
64 }
65
66 // postcss-bem-linter: end
67}
68
69///
70/// Customizes the color of the helper text following an enabled text-field.
71/// @param {Color} $color - The desired helper text color.
72///
73@mixin helper-text-color($color, $query: feature-targeting.all()) {
74 &:not(.mdc-text-field--disabled) {
75 @include helper-text-color_($color, $query);
76 }
77}
78
79///
80/// Customizes the color of the helper text following a disabled text-field.
81/// @param {Color} $color - The desired helper text color.
82///
83@mixin disabled-helper-text-color($color, $query: feature-targeting.all()) {
84 &.mdc-text-field--disabled {
85 @include helper-text-color_($color, $query);
86 }
87}
88
89@mixin helper-text-validation-color($color, $query: feature-targeting.all()) {
90 &:not(.mdc-text-field--disabled) {
91 @include helper-text-validation-color_($color, $query);
92 }
93}
94
95// Private mixins
96
97@mixin helper-text-color_($color, $query: feature-targeting.all()) {
98 $feat-color: feature-targeting.create-target($query, color);
99
100 + .mdc-text-field-helper-line .mdc-text-field-helper-text {
101 @include feature-targeting.targets($feat-color) {
102 @include theme.property(color, $color);
103 }
104 }
105}
106
107@mixin helper-text-validation-color_($color, $query: feature-targeting.all()) {
108 $feat-color: feature-targeting.create-target($query, color);
109
110 &.mdc-text-field--invalid
111 + .mdc-text-field-helper-line
112 .mdc-text-field-helper-text--validation-msg {
113 @include feature-targeting.targets($feat-color) {
114 @include theme.property(color, $color);
115 }
116 }
117}