-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathform-group.scss
297 lines (253 loc) · 7.62 KB
/
form-group.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
// stylelint-disable selector-max-compound-selectors
// stylelint-disable selector-max-type
// Form groups
//
// Usage:
//
// <div class="form-group">
// <div class="form-group-header"> containing the label
// <div class="form-group-body"> containing the form elements
// </div>
.form-group {
// stylelint-disable-next-line primer/spacing
margin: 15px 0;
// Autocomplete with embedded icon
.form-control.autocomplete-embedded-icon-wrap {
&:focus-within {
background-color: var(--bgColor-default, var(--color-canvas-default));
}
}
// Text fields
.form-control {
// stylelint-disable-next-line primer/responsive-widths
width: 440px;
max-width: 100%;
// stylelint-disable-next-line primer/spacing
margin-right: 5px;
background-color: var(--bgColor-muted, var(--color-canvas-inset));
&:focus {
background-color: var(--bgColor-default, var(--color-canvas-default));
}
&.shorter {
width: 130px;
}
&.short {
width: 250px;
}
&.input-block,
&.long {
width: 100%;
}
}
// Textarea
// stylelint-disable selector-no-qualifying-type
textarea.form-control {
width: 100%;
height: 200px;
min-height: 200px;
&.short {
height: 50px;
min-height: 50px;
}
}
// stylelint-enable selector-no-qualifying-type
// The Label
dt, // TODO: Deprecate
.form-group-header {
// stylelint-disable-next-line primer/spacing
margin: 0 0 6px;
}
label {
// fix for chrome bug, see https://github.com/github/github/issues/53931
position: static;
}
&.flattened dt, // TODO: Deprecate
&.flattened .form-group-header {
float: left;
margin: 0;
// stylelint-disable-next-line primer/typography
line-height: 32px;
}
&.flattened dd, // TODO: Deprecate
&.flattened .form-group-body {
// stylelint-disable-next-line primer/typography
line-height: 32px;
}
//
// Form Elements
//
// stylelint-disable selector-no-qualifying-type
dd, // TODO: Deprecate
.form-group-body {
h4 {
margin: var(--base-size-4) 0 0;
&.is-error {
color: var(--fgColor-danger, var(--color-danger-fg));
}
&.is-success {
color: var(--fgColor-success, var(--color-success-fg));
}
+ .note {
margin-top: 0;
}
}
}
// stylelint-enable selector-no-qualifying-type
//
// Variants
//
&.required {
dt label::after, // TODO: Deprecate
.form-group-header label::after {
// stylelint-disable-next-line primer/spacing
padding-left: 5px;
color: var(--fgColor-danger, var(--color-danger-fg));
content: '*';
}
}
// Form AJAX states
//
// Form fields that need feedback for AJAX loading, success
// states and errored states.
.success,
.error,
.indicator {
display: none;
// stylelint-disable-next-line primer/typography
font-size: $font-size-small;
// stylelint-disable-next-line primer/typography
font-weight: $font-weight-bold;
}
&.loading {
opacity: 0.5;
.indicator {
display: inline;
}
.spinner {
display: inline-block;
vertical-align: middle;
}
}
&.successful {
.success {
display: inline;
color: var(--fgColor-success, var(--color-success-fg));
}
}
// Form validation
//
// Our inline errors
&.successed,
&.warn,
&.errored {
.success,
.warning,
.error {
position: absolute;
z-index: 10;
display: block; // Show up in errored/warn state
max-width: 450px; // Keep our long errors readable
padding: var(--base-size-4) var(--base-size-8);
margin: var(--base-size-8) 0 0;
// stylelint-disable-next-line primer/typography
font-size: $font-size-small;
// stylelint-disable-next-line primer/typography
font-weight: $font-weight-normal;
// stylelint-disable-next-line primer/borders
border-style: $border-style;
// stylelint-disable-next-line primer/borders
border-width: $border-width;
// stylelint-disable-next-line primer/borders
border-radius: $border-radius;
&::after,
&::before {
position: absolute;
bottom: 100%;
// stylelint-disable-next-line primer/spacing
left: 10px;
z-index: 15;
width: 0;
height: 0;
pointer-events: none;
content: ' ';
// stylelint-disable-next-line primer/borders, primer/colors
border: $border-style transparent;
}
&::after {
// stylelint-disable-next-line primer/borders
border-width: 5px;
}
&::before {
// stylelint-disable-next-line primer/spacing
margin-left: -1px;
// stylelint-disable-next-line primer/borders
border-width: 6px;
}
}
}
&.successed {
.success {
color: var(--fgColor-default, var(--color-fg-default));
background-color: var(--bgColor-default, var(--color-canvas-default)); // Makes sure the background is opaque to cover any content underneath
background-image: linear-gradient(var(--bgColor-success-muted, var(--bgColor-success-muted, var(--color-success-subtle))), var(--color-success-subtle));
border-color: var(--borderColor-success-muted, var(--color-success-muted));
&::after {
border-bottom-color: var(--borderColor-success-muted, var(--color-success-muted));
}
&::before {
border-bottom-color: var(--borderColor-success-muted, var(--color-success-muted));
}
}
}
&.warn {
.form-control:not(:focus, :focus-visible) {
border-color: var(--borderColor-attention-emphasis, var(--color-attention-emphasis));
}
.warning {
color: var(--fgColor-default, var(--color-fg-default));
background-color: var(--bgColor-default, var(--color-canvas-default)); // Makes sure the background is opaque to cover any content underneath
background-image: linear-gradient(var(--bgColor-attention-muted, var(--bgColor-attention-muted, var(--color-attention-subtle))), var(--color-attention-subtle));
border-color: var(--borderColor-attention-muted, var(--color-attention-muted));
&::after {
border-bottom-color: var(--borderColor-attention-muted, var(--color-attention-muted));
}
&::before {
border-bottom-color: var(--borderColor-attention-muted, var(--color-attention-muted));
}
}
}
&.errored {
.form-control:not(:focus, :focus-visible) {
border-color: var(--borderColor-danger-emphasis, var(--color-danger-emphasis));
}
label {
color: var(--fgColor-danger, var(--color-danger-fg));
}
.error {
color: var(--fgColor-default, var(--color-fg-default));
background-color: var(--bgColor-default, var(--color-canvas-default)); // Makes sure the background is opaque to cover any content underneath
background-image: linear-gradient(var(--bgColor-danger-muted, var(--bgColor-danger-muted, var(--color-danger-subtle))), var(--color-danger-subtle));
border-color: var(--borderColor-danger-muted, var(--color-danger-muted));
&::after {
border-bottom-color: var(--borderColor-danger-muted, var(--color-danger-muted));
}
&::before {
border-bottom-color: var(--borderColor-danger-muted, var(--color-danger-muted));
}
}
}
}
// tooltip
.note {
min-height: 17px;
// stylelint-disable-next-line primer/spacing
margin: var(--base-size-4) 0 2px;
// stylelint-disable-next-line primer/typography
font-size: $font-size-small;
color: var(--fgColor-muted, var(--color-fg-muted));
.spinner {
// stylelint-disable-next-line primer/spacing
margin-right: 3px;
vertical-align: middle;
}
}