-
Notifications
You must be signed in to change notification settings - Fork 24
/
vaadin-text-field-styles.html
267 lines (218 loc) · 7.78 KB
/
vaadin-text-field-styles.html
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<link rel="import" href="../../../vaadin-lumo-styles/color.html">
<link rel="import" href="../../../vaadin-lumo-styles/sizing.html">
<link rel="import" href="../../../vaadin-lumo-styles/spacing.html">
<link rel="import" href="../../../vaadin-lumo-styles/style.html">
<link rel="import" href="../../../vaadin-lumo-styles/typography.html">
<link rel="import" href="../../../vaadin-lumo-styles/mixins/required-field.html">
<dom-module id="lumo-text-field" theme-for="vaadin-text-field">
<template>
<style include="lumo-required-field">
:host {
--lumo-text-field-size: var(--lumo-size-m);
color: var(--lumo-body-text-color);
font-size: var(--lumo-font-size-m);
font-family: var(--lumo-font-family);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-tap-highlight-color: transparent;
padding: var(--lumo-space-xs) 0;
}
:host::before {
height: var(--lumo-text-field-size);
box-sizing: border-box;
display: inline-flex;
align-items: center;
}
:host([focused]:not([readonly])) [part="label"] {
color: var(--lumo-primary-text-color);
}
[part="value"],
[part="input-field"] ::slotted([part="value"]) {
cursor: inherit;
min-height: var(--lumo-text-field-size);
padding: 0 0.25em;
--_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent, #000 1.25em);
-webkit-mask-image: var(--_lumo-text-field-overflow-mask-image);
}
[part="value"]:focus {
-webkit-mask-image: none;
mask-image: none;
}
/*
TODO: CSS custom property in `mask-image` causes crash in Edge
see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15415089/
*/
@-moz-document url-prefix() {
[part="value"],
[part="input-field"] ::slotted([part="value"]) {
mask-image: var(--_lumo-text-field-overflow-mask-image);
}
}
[part="value"]::-webkit-input-placeholder {
color: inherit;
transition: opacity 0.175s 0.05s;
opacity: 0.5;
}
[part="value"]:-ms-input-placeholder {
color: inherit;
opacity: 0.5;
}
[part="value"]::-moz-placeholder {
color: inherit;
transition: opacity 0.175s 0.05s;
opacity: 0.5;
}
[part="value"]::placeholder {
color: inherit;
transition: opacity 0.175s 0.1s;
opacity: 0.5;
}
[part="input-field"] {
border-radius: var(--lumo-border-radius);
background-color: var(--lumo-contrast-10pct);
padding: 0 calc(0.375em + var(--lumo-border-radius) / 4 - 1px);
font-weight: 500;
line-height: 1;
position: relative;
cursor: text;
box-sizing: border-box;
}
/* Used for hover and activation effects */
[part="input-field"]::after {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
border-radius: inherit;
pointer-events: none;
background-color: var(--lumo-contrast-50pct);
opacity: 0;
transition: transform 0.15s, opacity 0.2s;
transform-origin: 100% 0;
}
/* Hover */
:host(:hover:not([readonly]):not([focused])) [part="label"] {
color: var(--lumo-body-text-color);
}
:host(:hover:not([readonly]):not([focused])) [part="input-field"]::after {
opacity: 0.1;
}
/* Touch device adjustment */
@media (pointer: coarse) {
:host(:hover:not([readonly]):not([focused])) [part="label"] {
color: var(--lumo-secondary-text-color);
}
:host(:hover:not([readonly]):not([focused])) [part="input-field"]::after {
opacity: 0;
}
:host(:active:not([readonly]):not([focused])) [part="input-field"]::after {
opacity: 0.2;
}
}
/* Trigger when not focusing using the keyboard */
:host([focused]:not([focus-ring]):not([readonly])) [part="input-field"]::after {
transform: scaleX(0);
transition-duration: 0.15s, 1s;
}
/* Focus-ring */
:host([focus-ring]) [part="input-field"] {
box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
}
/* Read-only and disabled */
:host([readonly]) [part="value"]::-webkit-input-placeholder,
:host([disabled]) [part="value"]::-webkit-input-placeholder {
opacity: 0;
}
:host([readonly]) [part="value"]:-ms-input-placeholder,
:host([disabled]) [part="value"]:-ms-input-placeholder {
opacity: 0;
}
:host([readonly]) [part="value"]::-moz-placeholder,
:host([disabled]) [part="value"]::-moz-placeholder {
opacity: 0;
}
:host([readonly]) [part="value"]::placeholder,
:host([disabled]) [part="value"]::placeholder {
opacity: 0;
}
/* Read-only */
:host([readonly]) [part="input-field"] {
color: var(--lumo-secondary-text-color);
background-color: transparent;
cursor: default;
}
:host([readonly]) [part="input-field"]::after {
background-color: transparent;
opacity: 1;
border: 1px dashed var(--lumo-contrast-30pct);
}
/* Disabled style */
:host([disabled]) {
pointer-events: none;
}
:host([disabled]) [part="input-field"] {
background-color: var(--lumo-contrast-5pct);
}
:host([disabled]) [part="label"],
:host([disabled]) [part="value"],
:host([disabled]) [part="input-field"] ::slotted(*) {
color: var(--lumo-disabled-text-color);
-webkit-text-fill-color: var(--lumo-disabled-text-color);
}
/* Invalid style */
:host([invalid]) [part="input-field"] {
background-color: var(--lumo-error-color-10pct);
}
:host([invalid]) [part="input-field"]::after {
background-color: var(--lumo-error-color-50pct);
}
:host([invalid][focus-ring]) [part="input-field"] {
box-shadow: 0 0 0 2px var(--lumo-error-color-50pct);
}
/* Small theme */
:host([theme~="small"]) {
font-size: var(--lumo-font-size-s);
--lumo-text-field-size: var(--lumo-size-s);
}
:host([theme~="small"][has-label]) [part="label"] {
font-size: var(--lumo-font-size-xs);
}
:host([theme~="small"][has-label]) [part="error-message"] {
font-size: var(--lumo-font-size-xxs);
}
/* Text align */
:host([theme~="align-center"]) [part="value"] {
text-align: center;
--_lumo-text-field-overflow-mask-image: none;
}
:host([theme~="align-right"]) [part="value"] {
text-align: right;
--_lumo-text-field-overflow-mask-image: none;
}
@-moz-document url-prefix() {
/* Firefox is smart enough to align overflowing text to right */
:host([theme~="align-right"]) [part="value"] {
--_lumo-text-field-overflow-mask-image: linear-gradient(to right, transparent 0.25em, #000 1.5em);
}
}
/* Slotted content */
[part="input-field"] ::slotted(:not([part]):not(iron-icon)) {
color: var(--lumo-secondary-text-color);
font-weight: 400;
}
/* Slotted icons */
[part="input-field"] ::slotted(iron-icon) {
color: var(--lumo-contrast-60pct);
width: var(--lumo-icon-size-m);
height: var(--lumo-icon-size-m);
}
/* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */
[part="input-field"] ::slotted(iron-icon[icon^="vaadin:"]) {
padding: 0.25em;
box-sizing: border-box !important;
}
</style>
</template>
</dom-module>