-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy path_forms.scss
249 lines (195 loc) · 4.91 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
// Forms
// ==========================================================================
// Contents:
//
// 1. Helpers
// 2. Form wrappers
// 3. Form labels
// 4. Form hints
// 5. Form controls
// 6. Form control widths
// 7. Browser accessibility fixes
// 1. Helpers
// ==========================================================================
// Fieldset is used to group more than one .form-group
fieldset {
@extend %contain-floats;
width: 100%;
// Avoid extra vertical space (caused by fieldsets preventing margin collapse) when fieldsets with an h1 in the legend appear after the error-summary element.
// (Class used instead of adjacent sibling selector for IE 8 compatibility.)
&.after-error-summary {
margin-top: -$gutter-half;
@include media(tablet) {
margin-top: -$gutter;
}
}
}
// Hack to let legends or elements within legends have margins in webkit browsers
legend {
overflow: hidden;
}
// Fix left hand gap in IE7 and below
@include ie-lte(7) {
legend {
margin-left: -7px;
}
}
// Remove margin under textarea in Chrome and FF
textarea {
display: block;
}
// 2. Form wrappers
// ==========================================================================
.form-section,
.form-group {
@extend %contain-floats;
@include box-sizing(border-box);
}
// Form section is used to wrap .form-group and has twice its margin
.form-section {
margin-bottom: $gutter;
@include media(tablet) {
margin-bottom: $gutter * 2;
}
}
// Form group is used to wrap label and input pairs
.form-group {
margin-bottom: $gutter-half;
@include media(tablet) {
margin-bottom: $gutter;
}
}
// Form group related is used to reduce the space between label and input pairs
.form-group-related {
margin-bottom: 10px;
@include media(tablet) {
margin-bottom: 20px;
}
}
// Form group compound is used to reduce the space between label and input pairs
.form-group-compound {
margin-bottom: 10px;
}
// 3. Form labels
// ==========================================================================
// Form labels, or for legends styled to look like labels
// TODO: Amend so there is only one label style
.form-label,
.form-label-bold {
display: block;
color: $text-colour;
padding-bottom: 2px;
}
.form-label {
@include core-19;
}
.form-label-bold {
@include bold-19;
}
// Used for the 'or' in between block label options
.form-block {
float: left;
clear: left;
margin-top: -5px;
margin-bottom: 5px;
@include media(tablet) {
margin-top: 0;
margin-bottom: 10px;
}
}
// 4. Form hints
// ==========================================================================
// Form hints and example text are light grey and sit above a form control
.form-hint {
@include core-19;
display: block;
color: $secondary-text-colour;
font-weight: normal;
margin-top: -2px;
padding-bottom: 2px;
}
.form-label .form-hint,
.form-label-bold .form-hint {
margin-top: 0;
padding-bottom: 0;
}
// 5. Form controls
// ==========================================================================
// By default, form controls are 50% width for desktop,
// and 100% width for mobile
.form-control {
@include box-sizing(border-box);
@include core-19;
width: 100%;
padding: 5px 4px 4px;
// setting any background-color makes text invisible when changing colours to dark backgrounds in Firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=1335476)
// as background-color and color need to always be set together, color should not be set either
border: 2px solid $text-colour;
// TODO: Remove 50% width set for tablet and up
// !! BREAKING CHANGE !!
@include media(tablet) {
width: 50%;
}
}
// Allow a qualifying element, remove rounded corners from inputs and textareas
// scss-lint:disable QualifyingElement
input.form-control,
textarea.form-control {
// Disable inner shadow and remove rounded corners
-webkit-appearance: none;
border-radius: 0;
}
textarea.form-control {
// Disable opacity and background image for Firefox
opacity: 1;
background-image: none;
}
// scss-lint:enable QualifyingElement
// 6. Form control widths
// ==========================================================================
// TODO: Update these
// Form control widths
.form-control-3-4 {
width: 100%;
@include media(tablet) {
width: 75%;
}
}
.form-control-2-3 {
width: 100%;
@include media(tablet) {
width: 66.66%;
}
}
.form-control-1-2 {
width: 100%;
@include media(tablet) {
width: 50%;
}
}
.form-control-1-3 {
width: 100%;
@include media(tablet) {
width: 33.33%;
}
}
.form-control-1-4 {
width: 100%;
@include media(tablet) {
width: 25%;
}
}
.form-control-1-8 {
width: 100%;
@include media(tablet) {
width: 12.5%;
}
}
// 7. Browser accessibility fixes
// ==========================================================================
option:active,
option:checked,
select:focus::-ms-value {
color: $white;
background-color: $govuk-blue;
}