UNPKG

8.66 kBSCSSView Raw
1//
2// Copyright 2017 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 'sass:math';
24@use 'sass:color';
25@use '@material/density/variables' as density-variables;
26@use '@material/floating-label/variables' as floating-label-variables;
27@use '@material/notched-outline/variables' as notched-outline-variables;
28@use '@material/theme/theme-color';
29
30///
31/// Returns outlined text field floating label position for given height.
32///
33/// @todo Instead of adjusting `$positionY` with label box height that might change based on floating label font size
34/// wrap label in a child element to apply `transitionY(-50%)` to automatically offset based on box height.
35///
36@function get-outlined-label-position-y($text-field-height) {
37 @return math.div($text-field-height, 2) +
38 math.div(notched-outline-variables.$label-box-height, 2);
39}
40
41$error: error !default;
42$disabled-border: rgba(theme-color.prop-value(on-surface), 0.06) !default;
43$disabled-icon: rgba(theme-color.prop-value(on-surface), 0.3) !default;
44$bottom-line-hover: rgba(theme-color.prop-value(on-surface), 0.87) !default;
45$bottom-line-idle: rgba(theme-color.prop-value(on-surface), 0.42) !default;
46$label: rgba(theme-color.prop-value(on-surface), 0.6) !default;
47
48$ink-color: rgba(theme-color.prop-value(on-surface), 0.87) !default;
49$helper-text-color: rgba(theme-color.prop-value(on-surface), 0.6) !default;
50$icon-color: rgba(theme-color.prop-value(on-surface), 0.54) !default;
51$focused-label-color: rgba(theme-color.prop-value(primary), 0.87) !default;
52$placeholder-ink-color: rgba(theme-color.prop-value(on-surface), 0.54) !default;
53$affix-color: rgba(theme-color.prop-value(on-surface), 0.6) !default;
54
55$disabled-label-color: rgba(theme-color.prop-value(on-surface), 0.38) !default;
56$disabled-ink-color: rgba(theme-color.prop-value(on-surface), 0.38) !default;
57$disabled-placeholder-ink-color: rgba(
58 theme-color.prop-value(on-surface),
59 0.38
60) !default;
61$disabled-helper-text-color: rgba(
62 theme-color.prop-value(on-surface),
63 0.38
64) !default;
65$disabled-affix-color: rgba(theme-color.prop-value(on-surface), 0.38) !default;
66
67$background: color.mix(
68 theme-color.prop-value(on-surface),
69 theme-color.prop-value(surface),
70 4%
71) !default;
72$disabled-background: color.mix(
73 theme-color.prop-value(on-surface),
74 theme-color.prop-value(surface),
75 2%
76) !default;
77$secondary-text: rgba(theme-color.prop-value(on-surface), 0.6) !default;
78
79$outlined-idle-border: rgba(theme-color.prop-value(on-surface), 0.38) !default;
80$outlined-disabled-border: rgba(
81 theme-color.prop-value(on-surface),
82 0.06
83) !default;
84$outlined-hover-border: rgba(theme-color.prop-value(on-surface), 0.87) !default;
85
86$textarea-border: rgba(theme-color.prop-value(on-surface), 0.73) !default;
87$textarea-background: rgba(theme-color.prop-value(surface), 1) !default;
88$textarea-disabled-border-color: rgba(
89 theme-color.prop-value(on-surface),
90 0.26
91) !default;
92// cannot be transparent because multiline textarea input
93// will make text unreadable
94$textarea-disabled-background: rgba(249, 249, 249, 1) !default;
95
96$ripple-target: '.mdc-text-field__ripple';
97$outlined-stroke-width: 2px !default;
98$height: 56px !default;
99$minimum-height: 40px !default;
100$minimum-height-for-filled-label: 52px !default;
101$maximum-height: $height !default;
102$padding-horizontal: 16px !default;
103$density-scale: density-variables.$default-scale !default;
104$density-config: (
105 height: (
106 default: $height,
107 maximum: $maximum-height,
108 minimum: $minimum-height,
109 ),
110) !default;
111$shape-radius: small !default;
112$label-position-y: floating-label-variables.$position-y !default;
113$label-offset: 16px !default;
114// TODO(b/154350788): Remove this variable, it's not used internally but it is
115// externally in Angular
116/// @deprecated this variable will be removed in the future.
117/// Use get-outlined-label-position-y($height) instead
118$outlined-label-position-y: get-outlined-label-position-y($height) !default;
119$outlined-with-leading-icon-label-position-x: 32px !default;
120$textarea-outlined-label-position-y: 24.75px !default; // visually ~4dp from top to baseline
121$textarea-filled-label-position-y: 10.25px !default; // visually ~20dp from top to label baseline
122$helper-line-padding: 16px !default;
123$filled-baseline-top: 40px !default;
124$input-height: 28px !default;
125$textarea-label-top: 19px !default; // visually ~32dp from top to label baseline
126$textarea-outlined-label-top: $textarea-label-top -
127 notched-outline-variables.$border-width !default;
128$textarea-line-height: 1.5rem !default; // 24dp from baseline to baseline
129$textarea-input-handle-margin: 1px !default;
130// Outlined textarea's first line should be placed at the same position as
131// outlined textfield, and should look identical if it is 1 row. Since textfield
132// is centered and font metrics vary for where the baseline is, the best way to
133// ensure textarea and textfield align is with padding. At 56px height with a
134// 24px line-height, a centered textfield has 16px of top and bottom padding.
135// Textarea should use this to position itself.
136$textarea-outlined-input-margin-top: 16px !default;
137$textarea-outlined-input-margin-bottom: 16px !default;
138$textarea-outlined-density-config: (
139 margin-top: (
140 default: $textarea-outlined-input-margin-top,
141 maximum: $textarea-outlined-input-margin-top,
142 minimum: $textarea-outlined-input-margin-top - 8,
143 ),
144 margin-bottom: (
145 default: $textarea-outlined-input-margin-bottom,
146 maximum: $textarea-outlined-input-margin-bottom,
147 minimum: $textarea-outlined-input-margin-bottom - 8,
148 ),
149) !default; // remove 1/2 of scale to -4 for minimum
150$textarea-outlined-label-density-config: (
151 top: (
152 default: $textarea-outlined-label-top,
153 maximum: $textarea-outlined-label-top,
154 minimum: $textarea-outlined-label-top - 8,
155 ),
156) !default; // remove 1/2 of scale to -4 for minimum
157$textarea-filled-input-margin-top: 23px !default; // visually ~40dp from top to baseline
158$textarea-filled-input-margin-bottom: 9px !default; // visually ~16dp from baseline to bottom
159$textarea-filled-density-config: (
160 margin-bottom: (
161 default: $textarea-filled-input-margin-bottom,
162 maximum: $textarea-filled-input-margin-bottom,
163 minimum: $textarea-filled-input-margin-bottom - 4,
164 ),
165) !default; // scale to -1 for minimum
166$textarea-filled-label-density-config: (
167 top: (
168 default: $textarea-label-top,
169 maximum: $textarea-label-top,
170 minimum: $textarea-label-top - 2,
171 ),
172) !default; // remove 1/2 of scale to -1 for minimm
173$textarea-filled-no-label-input-margin-top: 16px !default; // see above explanation for outlined textarea margin
174$textarea-filled-no-label-input-margin-bottom: 16px !default; // see above explanation for outlined textarea margin
175$textarea-filled-no-label-density-config: (
176 margin-top: (
177 default: $textarea-filled-no-label-input-margin-top,
178 maximum: $textarea-filled-no-label-input-margin-top,
179 minimum: $textarea-filled-no-label-input-margin-top - 8,
180 ),
181 margin-bottom: (
182 default: $textarea-filled-no-label-input-margin-bottom,
183 maximum: $textarea-filled-no-label-input-margin-bottom,
184 minimum: $textarea-filled-no-label-input-margin-bottom - 8,
185 ),
186) !default; // remove 1/2 of scale to -4 for minimum
187$textarea-internal-counter-input-margin-bottom: 2px !default; // visually ~20dp from baseline to counter baseline
188$textarea-internal-counter-baseline-bottom: 16px !default;
189// Note that the scale factor is an eyeballed approximation of what's shown in the mocks.
190
191$prefix-padding: 2px !default;
192$prefix-end-aligned-padding: 12px !default;
193$suffix-padding: 12px !default;
194$suffix-end-aligned-padding: 2px !default;