-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
form-control.scss
286 lines (247 loc) · 7.56 KB
/
form-control.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
// Needs refactoring
// stylelint-disable selector-no-qualifying-type, selector-max-compound-selectors
// stylelint-disable selector-max-type
// Base form controls
//
// Overrides for common inputs for easier styling.
.form-control,
.form-select {
// stylelint-disable-next-line primer/spacing
padding: 5px 12px;
// stylelint-disable-next-line primer/typography
font-size: $body-font-size;
// stylelint-disable-next-line primer/typography
line-height: 20px;
color: var(--fgColor-default, var(--color-fg-default));
vertical-align: middle;
background-color: var(--bgColor-default, var(--color-canvas-default));
background-repeat: no-repeat; // Repeat and position set for form states (success, error, etc)
background-position: right 8px center; // For form validation. This keeps images 8px from right and centered vertically.
// stylelint-disable-next-line primer/borders, primer/colors
border: $border-width $border-style var(--control-borderColor-rest, var(--color-border-default));
// stylelint-disable-next-line primer/borders
border-radius: $border-radius;
box-shadow: var(--shadow-inset, var(--color-primer-shadow-inset));
transition: 80ms cubic-bezier(0.33, 1, 0.68, 1);
transition-property: color, background-color, box-shadow, border-color;
&:focus {
@include focusBoxShadowInset;
// remove fallback :focus if :focus-visible is supported
&:not(:focus-visible) {
border-color: transparent;
@include focusBoxShadowInset(1px, transparent);
}
}
// default focus state
&:focus-visible {
@include focusBoxShadowInset;
}
// override form controls with no border in focused state
&.border-0 {
&:focus,
&:focus-visible {
// stylelint-disable-next-line primer/borders, primer/colors
border: $border-width $border-style var(--borderColor-accent-emphasis, var(--color-accent-fg)) !important;
}
}
&[disabled],
fieldset[disabled] & {
color: var(--control-fgColor-disabled, var(--color-primer-fg-disabled));
background-color: var(--control-bgColor-disabled, var(--color-input-disabled-bg));
border-color: var(--control-borderColor-disabled, var(--color-border-default));
-webkit-text-fill-color: var(--control-fgColor-disabled, var(--color-primer-fg-disabled)); // Fix for Safari
opacity: 1; // Fix for Safari iOS
&::placeholder {
color: var(--control-fgColor-disabled, var(--color-primer-fg-disabled));
}
}
// Ensures inputs don't zoom on mobile iPhone but are body-font size on iPad
@supports (-webkit-touch-callout: none) {
// stylelint-disable-next-line primer/typography
font-size: $h4-size;
@include breakpoint(md) {
// stylelint-disable-next-line primer/typography
font-size: $body-font-size;
}
}
}
// Textarea
textarea.form-control {
padding-top: var(--base-size-8);
padding-bottom: var(--base-size-8);
// stylelint-disable-next-line primer/typography
line-height: $lh-default;
}
// Inputs with contrast for easy light gray backgrounds against white.
.input-contrast {
background-color: var(--bgColor-muted, var(--color-canvas-inset));
&:focus {
background-color: var(--bgColor-default, var(--color-canvas-default));
}
}
// Mini inputs, to match .minibutton
.input-sm {
min-height: $size-4;
// stylelint-disable-next-line primer/spacing
padding-top: 3px;
// stylelint-disable-next-line primer/spacing
padding-bottom: 3px;
// stylelint-disable-next-line primer/typography
font-size: $font-size-small;
// stylelint-disable-next-line primer/typography
line-height: 20px;
}
// Large inputs
.input-lg {
// stylelint-disable-next-line primer/typography
font-size: $h4-size;
}
// Full-width inputs
.input-block {
display: block;
width: 100%;
}
// Inputs with monospace text
.input-monospace {
// stylelint-disable-next-line primer/typography
font-family: $mono-font;
}
// Hide the icon that tries to autofill contact info in webkit
.input-hide-webkit-autofill {
&::-webkit-contacts-auto-fill-button {
position: absolute;
right: 0;
display: none !important;
pointer-events: none;
visibility: hidden;
}
}
// Checkboxes and Radiobuttons
//
// For checkboxes and radio button selections.
.form-checkbox {
// stylelint-disable-next-line primer/spacing
padding-left: 20px;
// stylelint-disable-next-line primer/spacing
margin: 15px 0;
vertical-align: middle;
label {
em.highlight {
position: relative;
left: calc(var(--base-size-4) * -1);
// stylelint-disable-next-line primer/spacing
padding: 2px var(--base-size-4);
font-style: normal;
background: var(--bgColor-attention-muted, var(--color-attention-subtle));
// stylelint-disable-next-line primer/borders
border-radius: $border-radius;
}
}
input[type='checkbox'],
input[type='radio'] {
float: left;
// stylelint-disable-next-line primer/spacing
margin: 5px 0 0 -20px;
vertical-align: middle;
}
.note {
display: block;
margin: 0;
// stylelint-disable-next-line primer/typography
font-size: $font-size-small;
// stylelint-disable-next-line primer/typography
font-weight: $font-weight-normal;
color: var(--fgColor-muted, var(--color-fg-muted));
}
}
.form-checkbox-details {
display: none;
}
.form-checkbox-details-trigger {
&:checked {
// child of sibling or sibling
~ * .form-checkbox-details,
~ .form-checkbox-details {
display: block;
}
}
}
// Field groups
//
// Wrap field groups in `<div.hfields>` to lay them out horizontally - great for
// the top of pages with autosave.
.hfields {
// stylelint-disable-next-line primer/spacing
margin: 15px 0;
@include clearfix;
.form-group {
float: left;
// stylelint-disable-next-line primer/spacing
margin: 0 30px 0 0;
dt, // TODO: Deprecate
.form-group-header {
label {
display: inline-block;
// stylelint-disable-next-line primer/spacing
margin: 5px 0 0;
color: var(--fgColor-muted, var(--color-fg-muted));
}
img {
position: relative;
// stylelint-disable-next-line primer/spacing
top: -2px;
}
}
}
.btn {
float: left;
// stylelint-disable-next-line primer/spacing
margin: 28px 25px 0 -20px;
}
.form-select {
// stylelint-disable-next-line primer/spacing
margin-top: 5px;
}
}
// Hide the up/down buttons in <input type="number"> in the login form, the
// input is used for two-factor auth codes, type="number" makes it more usable
// on phones
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
margin: 0;
appearance: none;
}
// Input groups
.form-actions {
@include clearfix;
.btn {
float: right;
+ .btn {
// stylelint-disable-next-line primer/spacing
margin-right: 5px;
}
}
}
.form-warning {
// stylelint-disable-next-line primer/spacing
padding: var(--base-size-8) 10px;
// stylelint-disable-next-line primer/spacing
margin: 10px 0;
// stylelint-disable-next-line primer/typography
font-size: $h5-size;
color: var(--fgColor-attention, var(--color-attention-fg));
background: var(--bgColor-attention-muted, var(--color-attention-subtle));
// stylelint-disable-next-line primer/borders, primer/colors
border: $border-width $border-style var(--borderColor-attention-emphasis, var(--color-attention-emphasis));
// stylelint-disable-next-line primer/borders
border-radius: $border-radius;
p {
margin: 0;
// stylelint-disable-next-line primer/typography
line-height: $lh-default;
}
a {
// stylelint-disable-next-line primer/typography
font-weight: $font-weight-bold;
}
}