-
Notifications
You must be signed in to change notification settings - Fork 0
/
_forms.scss
385 lines (333 loc) · 8.5 KB
/
_forms.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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
/*doc
---
title: Forms
name: styleguide-3_0_0
category: Forms
---
Forms are a major part of the checkout process, and it plays a large role in other parts of the site. Use the following styles to Zalorify your forms.
For the purposes of this styleguide, `<input type="submit">` is treated as a button. See the buttons section.
*/
input:not[type="submit"],
textarea {
width: 200px;
max-width: 100%;
}
.z-input-block {
display: block;
width: 100%;
min-height: 30px;
padding-right: 0;
padding-left: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
}
/*doc
---
title: Text Inputs
name: styleguide-3_1_0
category: Forms
---
Your trusty text input. Usually spotted near forms.
```html_example
<div class="full">
<input type="text" placeholder="What's your name?">
<input type="password" placeholder="Secret Password">
<input type="email" placeholder="Email">
<input type="tel" placeholder="1234-5678">
</div>
```
*/
/*doc
---
title: Selects
name: styleguide-3_2_0
category: Forms
---
Oh, so many options!
**NOTE:** Android 4.1 has a bug that renders HTML selects incorrectly if they have
styles attached. To bypass this, set the class `android-41` on the `body`.
```html_example
<div class="full">
<select>
<option>To be</option>
<option>Not to be</option>
</select>
</div>
```
*/
body:not(.android-41) select,
textarea,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"] {
display: inline-block;
min-height: 22px;
padding: 4px 6px;
margin-bottom: 4px;
font-size: 15px;
line-height: 25px;
vertical-align: middle;
box-sizing: border-box;
-o-box-sizing: border-box;
-ms-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
/*doc
---
title: Textarea
name: styleguide-3_3_0
category: Forms
---
Fill it in, fill it in.
```html_example
<div class="full">
<textarea placeholder="Tell me about yourself..."></textarea>
</div>
```
*/
textarea,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"] {
background-color: #fff;
border: 1px solid #ccc;
-webkit-appearance: none;
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus {
border-color: #00b09f;
outline: 0;
}
select:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
/*doc
---
title: Checkboxes
name: styleguide-3_4_0
category: Forms
---
Checkboxes are typically created inside labels
```html_example
<div class="full">
<label><input type="checkbox"> Send me a newsletter</label>
</div>
```
*/
/*doc
---
title: Radio Buttons
name: styleguide-3_5_0
category: Forms
---
These are also created inside labels
```html_example
<div class="full">
<label><input name="vacation" type="radio"> Go to Disneyland</label>
<label><input name="vacation" type="radio"> Go to Universal Studios</label>
</div>
```
*/
input[type="radio"],
input[type="checkbox"] {
width: auto;
margin: -2px 3px 0 0;
line-height: normal;
}
/*doc
---
title: Labels
name: styleguide-3_6_0
category: Forms
---
Labels can be used with any form element. Just precede the element with the
label. Use the `for` attribute to link the label to its form element.
Checkboxes and radio buttons are the only form elements that are placed inside
the label.
```html_example
<div class="full">
<label for="nickname">Nickname</label>
<input type="text" id="nickname">
</div>
<div class="full">
<label><input type="checkbox"> I love labels</label>
</div>
```
*/
label {
display: block;
margin-bottom: 0;
}
/*doc
---
title: Block level inputs
name: styleguide-3_8_0
category: Forms
---
Use `.z-input-block` to set the following elements as block-level:
- input[type="text"]
- input[type="password"]
- input[type="email"]
- input[type="tel"]
- select
- textarea
```html_example
<div class="full">
<input type="text" class="z-input-block" placeholder="Block text input">
<input type="password" class="z-input-block" placeholder="Block password input">
<input type="email" class="z-input-block" placeholder="Block email input">
<input type="tel" class="z-input-block" placeholder="Block tel input">
<select class="z-input-block"><option>Block select</option></select>
<textarea class="z-input-block" placeholder="Block textarea"></textarea>
</div>
```
### Appended input
Sometimes, a text input is paired with a button to initiate a form action,
such as a search. Or sometimes, a static element is appended to a text input
to represent a fixed aspect of the input. For example. when entering a
dollar amount, The user may enter "32", and the element appended may show
".00".
To attach an element to a text input, both the element and the input must be
wrapped in an element with the class *z-input-append*. In addition, the appended
element must have the class *add-on*.
**BROWSER BUG**: Inputs on Firefox mobile ~v20 do not respond to line-height.
The only `add-on` element that works on Firefox mobile is `<button>`.
So although any element works fine on non-Firefox browsers, use only `<button>`
on the live site.
**NOTE:** The examples below will overflow from its container.
For the purposes of this guide, this is normal and is not a bug.
```html_example
<div class="full">
<div class="z-input-append">
<input type="text">
<input type="submit" class="z-btn add-on" value="Search">
</div>
<div class="z-input-append">
<input type="text" placeholder="$24">
<div class="add-on">.00</div>
</div>
</div>
```
*/
.z-input-append {
display: inline-block;
white-space: nowrap;
vertical-align: middle;
}
.z-input-append input[type="text"],
.z-input-append input[type="email"],
.z-input-append input[type="tel"] {
display: inline-block;
margin-top: 1.616161px;
margin-right: 0;
border-left: 1px solid #ccc;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
border-right: none;
min-height: 20px; /* Firefox input bug fix. All elements except <button> work */
}
.z-input-append .add-on {
display: inline-block;
vertical-align: top;
margin-top: 1.616161px;
margin-left: -4px;
padding: 4px 8px;
border-top: 1px solid #ccc;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
line-height: 20px;
}
/*doc
---
title: Block Level Appended input
name: styleguide-3_8_1
category: Forms
---
To make an appended input group block-level, the structure will change a bit
from the above example. It must follow these rules:
- In addition to `z-input-append`, the class `z-input-block-append` must be added
to the wrapping element.
- The appended element must be placed **before** the text input in the HTML markup.
- The text input must be wrapped in an element with the class *z-input*.
```html_example
<div class="full">
<div class="z-input-append z-input-block-append">
<input type="submit" class="z-btn add-on" value="Search">
<div class="z-input">
<input type="text">
</div>
</div>
<div class="z-input-append z-input-block-append">
<div class="add-on">.00</div>
<div class="z-input">
<input type="text" placeholder="$24">
</div>
</div>
</div>
```
*/
.z-input-block-append {
width: 100%;
}
.z-input-block-append:before,
.z-input-block-append:after {
content: " ";
display: table;
}
.z-input-block-append:after {
clear: both;
}
.z-input-block-append .z-input {
overflow: hidden;
padding-right: 3px;
}
.z-input-block-append .add-on {
float: right;
}
.z-input-block-append .z-input input {
width: 100%;
}
/*doc
---
title: Inline Groups
name: styleguide-3_9_0
category: Forms
---
Wrap inputs with the class `inline-group` to semantically group them.
```html_example
<div class="full">
<div class="inline-group">
<label>Name</label>
<input type="text" style="width: 100px;">
</div>
<hr>
<div class="inline-group">
<select>
<option>Jan</option>
<option>Feb</option>
</select>
<select>
<option>1</option>
<option>2</option>
</select>
<select>
<option>1992</option>
<option>1993</option>
</select>
</div>
</div>
```
*/