Repository navigation
Expand file tree
/
Copy pathsemanticForms.scss
More file actions
414 lines (352 loc) · 12.1 KB
/
Copy pathsemanticForms.scss
File metadata and controls
414 lines (352 loc) · 12.1 KB
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
@use 'styles/globals.scss';
@use 'styles/inputs.scss';
@use 'styles/labels.scss';
@use 'styles/colspan.scss';
@use 'styles/tabs.scss';
@use 'styles/lowFlow.scss';
@use 'styles/layoutScope.scss' as *;
.semanticForms {
fieldset {
border-radius: var(--semanticFormsBorderRadius);
background: var(--semanticFormsFormSubBgColor);
border: 1px var(--semanticFormsSubBorderColor) solid;
display: flex;
flex-direction: column;
gap: 10px;
padding: 10px 10px 20px 10px;
margin-bottom: 15px;
// nested fieldsets and details are darkened
fieldset, details {
background-color: var(--semanticFormsNestedFieldsetBgColor);
border: var(--semanticFormsNestedFieldsetBorder);
margin: 0;
}
}
// add opacity to styled inputs to prevent blending with background
//
// the nesting is wrapped in :where so that this weighs no more than the field rules it overrides, and wins over them by coming later. a search field keeps its own background, as it always has
:where(fieldset fieldset, fieldset details) {
input:where(:not([type=submit], [type=reset], [type=button], [type=image], [type=checkbox], [type=radio], [type=search])),
select,
textarea {
background-color: var(--semanticFormsNestedInputBgColor);
}
}
details {
box-sizing: border-box; // ensure sizings match across browsers
position: relative;
background-color: var(--semanticFormsFormSubBgColor);
border: 1px var(--semanticFormsSubBorderColor) solid;
border-radius: var(--semanticFormsBorderRadius);
display: flex;
flex-direction: column;
gap: 5px;
padding: 10px;
margin: 0;
min-height: calc(var(--semanticFormsFontSize) + 20px);
&::details-content {
visibility: hidden;
opacity: 0;
transition: opacity 250ms ease-in, visibility 0ms ease-in 250ms;
}
@supports (interpolate-size: allow-keywords) { // https://caniuse.com/wf-interpolate-size
transition: opacity 250ms ease-in, visibility 0ms ease-in 250ms, height 250ms;
&::details-content {
height: 0;
overflow: hidden;
transition: height 250ms, content-visibility 250ms;
transition-behavior: allow-discrete;
}
}
summary {
cursor: pointer;
margin: 0;
margin-bottom: 10px;
line-height: 1;
position: absolute;
// the ink offset comes off here as it does elsewhere, so the words rather than the box holding them line up
top: calc(10px - var(--semanticFormsTextInkOffset, 0px));
left: 22px;
transition: top 250ms;
&::-webkit-details-marker,
&::marker {
content: ''; // hide default arrow, as it cannot be animated
}
&::before {
// custom arrow
content: '';
border-width: .4rem;
border-style: solid;
border-color: transparent transparent transparent var(--semanticFormsTextColor);
position: absolute;
// centered on the line of text beside it: the arrow is 0.8rem tall and the line is 1em, so half the difference puts it in the middle, less the measured ink offset because the letters do not sit in the middle of their own line either. it was pinned to the top of the line before
top: calc((1em - 0.8rem) / 2 + var(--semanticFormsFieldTextInkOffset, 0px));
// far enough from the words to read as a separate mark rather than part of the first letter
left: -14px;
transform: rotate(0);
transform-origin: .2rem 50%;
transition: 250ms transform ease;
}
}
&[open] {
padding-top: 30px;
&::details-content {
visibility: visible;
opacity: 1;
transition: opacity 250ms ease-in, visibility 0ms ease-in 0ms;
}
@supports (interpolate-size: allow-keywords) {
&::details-content {
height: auto;
}
}
summary {
&::before {
transform: rotate(90deg);
}
}
& > dl:first-of-type#{$notCustomLayout} {
margin-top: 15px;
margin-bottom: 15px;
}
}
// opening and closing the panel changes its height, and the marker beside the summary turns: both are motion, and both are dropped for a visitor who asked for less of it. the fade is a colour change rather than movement, so it is left running
@media (prefers-reduced-motion: reduce) {
@supports (interpolate-size: allow-keywords) {
transition: opacity 250ms ease-in, visibility 0ms ease-in 250ms;
&::details-content {
transition: none;
}
}
summary {
transition: none;
&::before {
transition: none;
}
}
}
}
details details,
details fieldset {
margin-top: 10px;
background-color: var(--semanticFormsNestedFieldsetBgColor);
border: var(--semanticFormsNestedFieldsetBorder);
}
details details[open] summary::before {
transform: rotate(90deg);
}
details details:not([open]) summary::before {
transform: rotate(0deg);
}
// the grid layout. none of it applies inside a customLayout element, where the app lays the <dl> out itself: see layoutScope.scss
dl#{$notCustomLayout} {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(var(--semanticFormsInputMinWidth), var(--semanticFormsInputColumnMaxWidth)));
gap: 10px;
margin: 0;
div {
position: relative;
width: 100%;
max-width: var(--semanticFormsInputMaxWidth);
&:has([data-max-content]) {
min-width: 150px;
max-width: max-content;
dd {
width: max-content;
input, select {
// this is not currently supported in FireFox or Safari, and is progressively enhanced with JS
field-sizing: content;
min-width: 150px;
max-width: max-content;
}
}
}
// hide labels for singular buttons
&:has(dd > button:only-child, dd > input[type=button]:only-child, dd > input[type=submit]:only-child, dd > input[type=reset]:only-child) {
dt label {
display: none;
}
}
dd {
position: relative;
display: flex;
flex-direction: column;
gap: 10px;
max-width: 100%;
// checkbox/radio
&.singleCheckbox,
&.singleRadio {
display: grid;
grid-template-columns: 15px 1fr;
align-items: center;
padding-left: 11px;
gap: 5px 10px;
// a switch is wider than a checkbox, so it needs a wider column to sit in
&:has(input[type=checkbox][switch]) {
grid-template-columns: 34px 1fr;
}
// anything that is not the radio/checkbox and its label
& > :not(input[type='checkbox'], input[type='radio'], label) {
grid-column: 1 / -1;
}
// additional label takes up entire width
label:nth-of-type(2) {
grid-column: 1 / -1;
padding: 0 10px;
font-size: small;
color: var(--semanticFormsTextColor);
}
}
&.singleRadio > input {
margin: 0;
}
// checkbox/radio groups
&.checkboxes, &.radios {
ul {
display: flex;
flex-direction: column;
margin-top: var(--semanticFormsInputTopMargin);
padding-left: 10px;
gap: 5px;
li {
display: flex;
align-items: center;
gap: 5px;
}
}
// checkbox subtext
& > label {
padding-left: 20px;
font-size: small;
color: var(--semanticFormsTextColor);
}
}
// singular button
&:has(button:only-child, input[type=button]:only-child, input[type=submit]:only-child, input[type=reset]:only-child) {
margin-left: 0;
button, input[type=button], input[type=submit], input[type=reset] {
height: var(--semanticFormsInputHeight);
}
}
// place buttons next to input
&:has(input ~ button:not(.clear, .show), input ~ input[type=submit], input ~ input[type=reset], input ~ input[type=button], select ~ button:not(.clear, .show),select ~ input[type=submit],select ~ input[type=reset],select ~ input[type=button]) {
display: grid;
grid-template-columns: 2fr 1fr;
button.clear, button.show {
right: 36%; // adjust clear/show button to grid
}
// inputs take up first section of columns
input:not([type="submit"]), select, textarea {
grid-row: 1 / 2;
grid-column: 1 / 2;
}
// buttons take up second section of columns
button:not(.clear, .show),
input[type="submit"]:not(.clear, .show),
input[type="button"]:not(.clear, .show) {
grid-row: 1 / 2;
grid-column: 2 / 3;
width: 100%;
max-width: 100%;
// reduced from the default so more of the button's text fits. the vertical halves carry the measured ink offset, as they do on every other control, so the words sit in the middle of the button rather than the box holding them sitting there
padding: calc(10px - var(--semanticFormsFieldTextInkOffset, 0px)) 10px calc(10px + var(--semanticFormsFieldTextInkOffset, 0px));
height: var(--semanticFormsInputHeight);
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
display: inline-block;
}
label:nth-of-type(2),
label:not(.floatLabelFormAnimatedLabel) {
grid-row: 2 / 3;
grid-column: 1 / -1;
}
}
}
}
}
p {
// input/label combo
&:has(input:not([type='checkbox'], [type='radio']), textarea, label) {
display: flex;
flex-direction: column;
gap: 5px;
}
// checkbox or radio/label combo
&:has(input[type='checkbox'], input[type='radio']) {
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
}
}
menu:has(li > input, li > label, li > button, li > select, li > textarea),
ul:has(li > input, li > label, li > button, li > select, li > textarea) {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
list-style-type: none;
li {
display: flex;
align-items: center;
}
}
div#{$notCustomLayout}:has(.align-start) {
display: flex;
justify-content: start;
}
div#{$notCustomLayout}:has(.align-center) {
display: flex;
justify-content: center;
}
div#{$notCustomLayout}:has(.align-end) {
display: flex;
justify-content: end;
}
}
.semanticForms table,
table.semanticForms {
table-layout: fixed;
width: 100%;
border-spacing: 0;
border: var(--semanticFormsBorder);
border-radius: 10px;
margin-bottom: 15px;
overflow: hidden;
tr.title th {
background-color: var(--semanticFormsTableTitleColor);
}
th {
background-color: var(--semanticFormsTableHeaderColor);
font-weight: bold;
}
tr:nth-child(odd) td {
background-color: var(--semanticFormsTableOddColor);
}
tr:nth-child(even) td {
background-color: var(--semanticFormsTableEvenColor);
}
td, th {
border-right: var(--semanticFormsTableBorder);
border-bottom: var(--semanticFormsTableBorder);
padding: 7px 10px;
}
th:last-of-type, td:last-of-type {
border-right: none;
}
// the last row draws no bottom border, since the table draws its own. in a table with a footer, that is the footer's last row, and the body's last row keeps its border, which divides the body from the footer
tbody:last-child tr:last-child, tfoot tr:last-child {
th, td {
border-bottom: none;
}
}
// the table's overflow is hidden to clip its cells to its rounded corners, which clips the caption too, cutting the edge off a letter that reaches past it, such as the T at the start of a caption. a little padding keeps the caption's letters clear of the edge
caption {
padding: 0 3px;
}
// adjust styling of button menus in tables
menu:has(li > input, li > label, li > button, li > select, li > textarea, li > a) {
width: max-content;
}
}