semantic-forms 5.3.17 → 5.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/semantic-forms.cjs +24 -6
- package/dist/semantic-forms.cjs.map +1 -1
- package/dist/semantic-forms.css +203 -19
- package/dist/semantic-forms.css.map +1 -1
- package/dist/semantic-forms.js +24 -6
- package/dist/semantic-forms.js.map +1 -1
- package/dist/semantic-forms.min.js +1 -1
- package/dist/semantic-forms.min.js.map +1 -1
- package/dist/semantic-forms.min.mjs +1 -1
- package/dist/semantic-forms.min.mjs.map +1 -1
- package/dist/semantic-forms.mjs +24 -6
- package/dist/semantic-forms.mjs.map +1 -1
- package/docs/statics/css/semantic-forms-styles.scss +6 -2
- package/docs/statics/js/semantic-forms-main.js +13 -3
- package/docs/statics/pages/fullDemo.html +89 -0
- package/docs/statics/pages/layout.html +74 -0
- package/docs/statics/pages/layouts/main.html +2 -0
- package/docs/statics/pages/theming.html +6 -0
- package/docs/statics/pages/usage.html +10 -0
- package/package.json +7 -5
- package/semanticForms.scss +19 -0
- package/styles/colspan.scss +316 -0
- package/styles/globals.scss +202 -0
- package/styles/inputs.scss +473 -0
- package/styles/labels.scss +316 -0
- package/styles/layoutScope.scss +4 -0
- package/styles/lowFlow.scss +166 -0
- package/styles/tabs.scss +188 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
@use 'layoutScope.scss' as *;
|
|
2
|
+
|
|
3
|
+
// the resting float label's line height, which its centering calculation depends on
|
|
4
|
+
//
|
|
5
|
+
// tall enough to hold a descender. a line height of 1.2 gives a box shorter than some fonts need for the tail of a g or a p, and the label clips its overflow in order to end long text with an ellipsis, so the tail was being cut off. the distance the label travels when it floats is written as a share of this height, and was adjusted to match, so the floated label lands exactly where it did before at any font size
|
|
6
|
+
$floatLabelLineHeight: 1.5;
|
|
7
|
+
|
|
8
|
+
.semanticForms {
|
|
9
|
+
input[type=checkbox] + label:first-of-type,
|
|
10
|
+
input[type=radio] + label:first-of-type {
|
|
11
|
+
// the label sits beside the box rather than inside it, so it is nudged to line the words up with the middle of the box, less the measured ink offset
|
|
12
|
+
//
|
|
13
|
+
// taking the offset off once rather than twice: measured from drawn pixels in firefox and chrome on both linux and mac, one lands every one of them within half a pixel, while twice is out by a full pixel on mac, where the offset is negative and so adds padding rather than removing it
|
|
14
|
+
padding-top: calc(2px - var(--semanticFormsTextInkOffset, 0px));
|
|
15
|
+
font-size: var(--semanticFormsInputFontSize);
|
|
16
|
+
cursor: var(--semanticFormsCursor, pointer);
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: 5px;
|
|
20
|
+
|
|
21
|
+
span.required {
|
|
22
|
+
cursor: help;
|
|
23
|
+
pointer-events: auto;
|
|
24
|
+
color: red;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
span.help {
|
|
28
|
+
display: grid;
|
|
29
|
+
place-items: center;
|
|
30
|
+
cursor: help;
|
|
31
|
+
pointer-events: auto;
|
|
32
|
+
|
|
33
|
+
svg {
|
|
34
|
+
width: 80%;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// the float labels are part of the grid layout, so they do not apply inside a customLayout element, where the enhancement does not add the floatLabelForm class anyway: see layoutScope.scss
|
|
40
|
+
.floatLabelForm#{$notCustomLayout} {
|
|
41
|
+
div {
|
|
42
|
+
dt {
|
|
43
|
+
position: relative;
|
|
44
|
+
|
|
45
|
+
label {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: 5px;
|
|
49
|
+
z-index: 2; // ensure the hoverable icon is interactable
|
|
50
|
+
user-select: auto;
|
|
51
|
+
color: var(--semanticFormsTextColor);
|
|
52
|
+
font-size: var(--semanticFormsInputFontSize);
|
|
53
|
+
position: absolute;
|
|
54
|
+
transform-origin: left center;
|
|
55
|
+
transform: translateY(-100%) scale(0.7);
|
|
56
|
+
top: var(--semanticFormsInputTopMargin);
|
|
57
|
+
left: 10px;
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
text-overflow: ellipsis;
|
|
61
|
+
min-width: 0;
|
|
62
|
+
width: 100%;
|
|
63
|
+
|
|
64
|
+
span.help {
|
|
65
|
+
display: grid;
|
|
66
|
+
place-items: center;
|
|
67
|
+
cursor: help;
|
|
68
|
+
pointer-events: auto;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:has(dd input:required) {
|
|
74
|
+
dt {
|
|
75
|
+
label {
|
|
76
|
+
width: 100%;
|
|
77
|
+
padding-right: 10px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
label > span {
|
|
81
|
+
margin-left: 5px;
|
|
82
|
+
cursor: help;
|
|
83
|
+
pointer-events: auto;
|
|
84
|
+
color: red;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
dd:not(.singleCheckbox, .singleRadio, .checkboxes, .radios) {
|
|
90
|
+
input:not([type=submit], [type=reset], [type=button], [type=image]),
|
|
91
|
+
select,
|
|
92
|
+
textarea {
|
|
93
|
+
&:focus:not([type=checkbox], [type=radio], .no-float-label) ~ label:first-of-type,
|
|
94
|
+
&:not(:placeholder-shown):not(.no-float-label):not([type=checkbox]):not([type=radio]) ~ label:first-of-type {
|
|
95
|
+
color: var(--semanticFormsTextColor);
|
|
96
|
+
transform: translateY(-120%) scale(0.7);
|
|
97
|
+
width: 100%;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// an empty field has no clear button, so the resting label can use the space that was kept for it rather than being cut short
|
|
102
|
+
input:placeholder-shown:not(.no-float-label) ~ label:first-of-type {
|
|
103
|
+
width: calc(100% - 20px);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// hide float label if no-float-label class is present
|
|
107
|
+
input:not([type=submit], [type=reset], [type=button], [type=image]),
|
|
108
|
+
select,
|
|
109
|
+
textarea {
|
|
110
|
+
&:focus.no-float-label ~ label:first-of-type,
|
|
111
|
+
&:not(:placeholder-shown).no-float-label:not([type=checkbox]):not([type=radio]) ~ label:first-of-type {
|
|
112
|
+
display: none;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
select ~ label:first-of-type {
|
|
117
|
+
// force label to be correct color
|
|
118
|
+
color: var(--semanticFormsTextColor);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
button:not(.clear, .show),
|
|
122
|
+
input[type=submit]:not(.clear, .show) {
|
|
123
|
+
margin-top: var(--semanticFormsInputTopMargin);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// input label
|
|
127
|
+
//
|
|
128
|
+
// the resting label is centered on the field by measuring rather than by a fixed offset: its own box is the line height below, so half of whatever the field has left over puts it exactly in the middle. a hardcoded offset only centers the one font size it was written for, and is off by a fraction of a pixel everywhere else, which rounds to a visible pixel on a non-retina display
|
|
129
|
+
label:first-of-type {
|
|
130
|
+
position: absolute;
|
|
131
|
+
top: calc(var(--semanticFormsInputTopMargin) + (var(--semanticFormsInputHeight) - var(--semanticFormsInputFontSize) * #{$floatLabelLineHeight}) / 2 - var(--semanticFormsTextInkOffset, 0px));
|
|
132
|
+
left: 20px;
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
gap: 5px;
|
|
136
|
+
line-height: $floatLabelLineHeight;
|
|
137
|
+
font-size: var(--semanticFormsInputFontSize);
|
|
138
|
+
transform-origin: left center;
|
|
139
|
+
pointer-events: none;
|
|
140
|
+
transition: transform 250ms;
|
|
141
|
+
cursor: text;
|
|
142
|
+
|
|
143
|
+
// the transform is what puts the label above the field, so it stays; only the travel to get there goes
|
|
144
|
+
@media (prefers-reduced-motion: reduce) {
|
|
145
|
+
transition: none;
|
|
146
|
+
}
|
|
147
|
+
flex: 1;
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
text-overflow: ellipsis;
|
|
151
|
+
min-width: 0;
|
|
152
|
+
// the gap on the right keeps the words clear of the clear button
|
|
153
|
+
width: calc(100% - 35px);
|
|
154
|
+
user-select: none;
|
|
155
|
+
color: var(--semanticFormsPlaceholderColor);
|
|
156
|
+
touch-action: manipulation;
|
|
157
|
+
|
|
158
|
+
span.required {
|
|
159
|
+
cursor: help;
|
|
160
|
+
pointer-events: auto;
|
|
161
|
+
color: red;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
span.help {
|
|
165
|
+
display: grid;
|
|
166
|
+
place-items: center;
|
|
167
|
+
cursor: help;
|
|
168
|
+
pointer-events: auto;
|
|
169
|
+
|
|
170
|
+
svg {
|
|
171
|
+
width: 80%;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// focus-key styles
|
|
177
|
+
&:has(span.focus-key) {
|
|
178
|
+
// make room for focus key span
|
|
179
|
+
label:first-of-type {
|
|
180
|
+
width: calc(100% - 95px);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
span.focus-key {
|
|
184
|
+
// flex rather than block, so the centering set on this element further down still applies once it is shown. as a block it sits at the top of the field instead
|
|
185
|
+
display: flex;
|
|
186
|
+
|
|
187
|
+
kbd {
|
|
188
|
+
font-family: sans-serif;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
&:has(input:focus, select:focus, textarea:focus),
|
|
193
|
+
&:not(:has(input:placeholder-shown, textarea:placeholder-shown)) {
|
|
194
|
+
span.focus-key {
|
|
195
|
+
display: none;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// subtext label
|
|
201
|
+
label:nth-of-type(2) {
|
|
202
|
+
margin-top: -5px;
|
|
203
|
+
padding: 0 10px;
|
|
204
|
+
font-size: small;
|
|
205
|
+
color: var(--semanticFormsTextColor);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
input,
|
|
209
|
+
textarea,
|
|
210
|
+
select {
|
|
211
|
+
margin-top: var(--semanticFormsInputTopMargin);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
input,
|
|
215
|
+
textarea {
|
|
216
|
+
transition: opacity 250ms;
|
|
217
|
+
|
|
218
|
+
// hide placeholder content until input is focused
|
|
219
|
+
&::placeholder {
|
|
220
|
+
opacity: 0;
|
|
221
|
+
transition: opacity 250ms;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
&::-moz-placeholder {
|
|
225
|
+
opacity: 0;
|
|
226
|
+
transition: opacity 250ms;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&::-webkit-input-placeholder {
|
|
230
|
+
opacity: 0;
|
|
231
|
+
transition: opacity 250ms;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
&:-ms-input-placeholder {
|
|
235
|
+
opacity: 0;
|
|
236
|
+
transition: opacity 250ms;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// show placeholder content when focused
|
|
240
|
+
&:focus {
|
|
241
|
+
&::placeholder {
|
|
242
|
+
opacity: 1;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
&::-moz-placeholder {
|
|
246
|
+
opacity: 1;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
&::-webkit-input-placeholder {
|
|
250
|
+
opacity: 1;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
&:-ms-input-placeholder {
|
|
254
|
+
opacity: 1;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// keyboard shortcut indicator
|
|
260
|
+
span.focus-key {
|
|
261
|
+
color: var(--semanticFormsPlaceholderColor);
|
|
262
|
+
position: absolute;
|
|
263
|
+
// spans the field and centers its own contents, which keeps it centered whatever height the shortcut text turns out to be. centering that way puts the middle of the box on the middle of the field, and the letters sit off the middle of their own box by the measured amount, so that comes off here as it does elsewhere
|
|
264
|
+
top: calc(var(--semanticFormsInputTopMargin) - var(--semanticFormsTextInkOffset, 0px));
|
|
265
|
+
height: var(--semanticFormsInputHeight);
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: center;
|
|
268
|
+
// it sits over the field, and is a hint rather than a control
|
|
269
|
+
pointer-events: none;
|
|
270
|
+
right: 20px;
|
|
271
|
+
|
|
272
|
+
kbd {
|
|
273
|
+
line-height: 1;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// a number field draws its own stepper, which sits at the inner edge of the field rather than the outer one, so the hint has to clear the field's right padding as well as the stepper itself
|
|
278
|
+
&:has(input[type=number]) {
|
|
279
|
+
.focus-key {
|
|
280
|
+
right: 60px;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
&:has(input[type=search]) {
|
|
285
|
+
label:first-of-type {
|
|
286
|
+
left: 32px;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// data-max-content CSS
|
|
292
|
+
&:has([data-max-content]) {
|
|
293
|
+
max-width: max-content;
|
|
294
|
+
min-width: 150px;
|
|
295
|
+
|
|
296
|
+
dd {
|
|
297
|
+
width: max-content;
|
|
298
|
+
|
|
299
|
+
input, select {
|
|
300
|
+
// this is not currently supported in FireFox or Safari, and is progressively enhanced with JS
|
|
301
|
+
field-sizing: content;
|
|
302
|
+
min-width: 150px;
|
|
303
|
+
max-width: max-content;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
input, textarea {
|
|
310
|
+
&::placeholder {
|
|
311
|
+
color: var(--semanticFormsPlaceholderColor);
|
|
312
|
+
opacity: 1;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// the library's own layout of a <dl>, which is the grid, its column classes, the float labels and everything else that sizes, places, hides or moves a <dl>, <dt>, <dd> or the <div> around them, does not apply inside an element with the customLayout class. that class can go on the form, a fieldset or a <dl>, and inside it the app lays the <dl> out itself while the controls are still styled as they are anywhere else
|
|
2
|
+
//
|
|
3
|
+
// this is appended to the element in each of those rules that the class can be on or inside, such as `dl#{$notCustomLayout}`. it is written as :not(:where()) so that it adds no weight at all: the rules keep exactly the specificity they had, and the layouts that do not use the class are unchanged
|
|
4
|
+
$notCustomLayout: ':not(:where(.customLayout, .customLayout *))';
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
@use 'layoutScope.scss' as *;
|
|
2
|
+
|
|
3
|
+
// the layout without javascript, and the lowFlow layout. like the grid, none of this applies inside a customLayout element: see layoutScope.scss
|
|
4
|
+
form.semanticForms.lowFlow,
|
|
5
|
+
form.semanticForms:not(.semanticFormsActive) {
|
|
6
|
+
gap: 10px;
|
|
7
|
+
|
|
8
|
+
dl#{$notCustomLayout} {
|
|
9
|
+
gap: 10px;
|
|
10
|
+
margin-bottom: 0px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// single checkbox/radios
|
|
14
|
+
//
|
|
15
|
+
// the combinators inside :has() are relative to this div on purpose. without them any ancestor div holding a checkbox anywhere below it matches too, and these rules then apply to every field inside it rather than to the one wrapping the checkbox
|
|
16
|
+
div#{$notCustomLayout}:not(:has(> dd > ul)):has(> dd > input[type=checkbox], > dd > input[type=radio]) {
|
|
17
|
+
padding-left: 11px;
|
|
18
|
+
|
|
19
|
+
&:has(> dd > input[type=radio]) {
|
|
20
|
+
margin-top: -2px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
dt {
|
|
24
|
+
label {
|
|
25
|
+
transform: scale(1);
|
|
26
|
+
margin-top: 4px;
|
|
27
|
+
margin-left: -4px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// a switch is wider than a checkbox, so its label has to start further along the row to clear it; the offset is the 29px a checkbox gets plus the 16px of extra track
|
|
32
|
+
&:has(dd > input[type=checkbox][switch]) dt label {
|
|
33
|
+
padding-left: 45px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
dd {
|
|
37
|
+
margin-top: 0;
|
|
38
|
+
|
|
39
|
+
// additional info text
|
|
40
|
+
label {
|
|
41
|
+
font-size: small;
|
|
42
|
+
margin-top: -2px;
|
|
43
|
+
padding-left: 10px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
div#{$notCustomLayout}:has(.align-start) {
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
align-items: start;
|
|
51
|
+
|
|
52
|
+
dd {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: start;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
div#{$notCustomLayout}:has(.align-center) {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
align-items: center;
|
|
62
|
+
|
|
63
|
+
dd {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
div#{$notCustomLayout}:has(.align-end) {
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
align-items: end;
|
|
72
|
+
|
|
73
|
+
dd {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: end;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
dt#{$notCustomLayout} {
|
|
80
|
+
min-width: var(--semanticFormsInputMinWidth); // this matches the max-width of js-enabled inputs
|
|
81
|
+
|
|
82
|
+
label {
|
|
83
|
+
position: absolute;
|
|
84
|
+
display: block;
|
|
85
|
+
height: 11px;
|
|
86
|
+
transform: scale(0.7);
|
|
87
|
+
transform-origin: left center;
|
|
88
|
+
padding-left: 29px;
|
|
89
|
+
margin-top: -2px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// add required asterisk
|
|
93
|
+
&:has(+ dd input:required) {
|
|
94
|
+
label::after {
|
|
95
|
+
content: ' *';
|
|
96
|
+
color: red;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// checkbox/radio groups
|
|
102
|
+
dt#{$notCustomLayout} {
|
|
103
|
+
&:has(+ dd.checkboxes),
|
|
104
|
+
&:has(+ dd.radios) {
|
|
105
|
+
label {
|
|
106
|
+
padding-left: 15px;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.checkboxes#{$notCustomLayout} ul,
|
|
112
|
+
.radios#{$notCustomLayout} ul {
|
|
113
|
+
margin-top: var(--semanticFormsInputTopMargin);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
dd#{$notCustomLayout} {
|
|
117
|
+
margin-top: var(--semanticFormsInputTopMargin);
|
|
118
|
+
min-width: var(--semanticFormsInputMinWidth); // this matches the max-width of js-enabled inputs
|
|
119
|
+
|
|
120
|
+
// checkbox/radio groups
|
|
121
|
+
&.checkboxes,
|
|
122
|
+
&.radios {
|
|
123
|
+
margin-top: 0;
|
|
124
|
+
|
|
125
|
+
ul {
|
|
126
|
+
input[type=radio] {
|
|
127
|
+
margin-top: 3px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
label {
|
|
131
|
+
padding-top: 7px;
|
|
132
|
+
padding-left: 0;
|
|
133
|
+
font-size: var(--semanticFormsFontSize);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// additional text
|
|
138
|
+
ul + label {
|
|
139
|
+
margin-top: 0;
|
|
140
|
+
font-size: small;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// remove "x" padding
|
|
145
|
+
input:not([type=submit], [type=reset], [type=button], [type=image], [type=checkbox], [type=radio], [type=range]),
|
|
146
|
+
select,
|
|
147
|
+
textarea {
|
|
148
|
+
padding-right: 6px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// subtext
|
|
152
|
+
label {
|
|
153
|
+
padding-left: 10px;
|
|
154
|
+
margin-top: -5px;
|
|
155
|
+
font-size: small;
|
|
156
|
+
color: var(--semanticFormsPlaceholderColor);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// inline buttons
|
|
160
|
+
button:not(.clear, .show),
|
|
161
|
+
input[type=submit]:not(.clear, .show),
|
|
162
|
+
input[type=button]:not(.clear, .show) {
|
|
163
|
+
margin-top: 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
package/styles/tabs.scss
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
.semanticForms {
|
|
2
|
+
// before the enhancement runs this is a plain stack of fieldsets, which is how it stays in a browser without javascript. the rules below only apply once the tabs have been built
|
|
3
|
+
.tabs.semanticFormsTabsActive {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
margin-bottom: 15px;
|
|
7
|
+
|
|
8
|
+
.tabList {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
align-items: flex-end;
|
|
12
|
+
gap: 3px;
|
|
13
|
+
|
|
14
|
+
// the selected tab sits over the panel's top border to join the two together
|
|
15
|
+
margin-bottom: -1px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
button[role=tab] {
|
|
19
|
+
appearance: none;
|
|
20
|
+
cursor: var(--semanticFormsCursor, pointer);
|
|
21
|
+
font-family: inherit;
|
|
22
|
+
font-size: var(--semanticFormsInputFontSize);
|
|
23
|
+
line-height: 1;
|
|
24
|
+
color: var(--semanticFormsTextColor);
|
|
25
|
+
margin: 0;
|
|
26
|
+
padding: 9px 20px;
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
text-overflow: ellipsis;
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
|
|
32
|
+
// an unselected tab is raised like the library's buttons are
|
|
33
|
+
background-image: linear-gradient(to bottom, var(--semanticFormsButtonGradientLight) 0%, var(--semanticFormsButtonGradientDark) 100%);
|
|
34
|
+
background-origin: border-box;
|
|
35
|
+
border: 1px solid var(--semanticFormsSubBorderColor);
|
|
36
|
+
border-radius: var(--semanticFormsBorderRadius) var(--semanticFormsBorderRadius) 0 0;
|
|
37
|
+
transition: padding 120ms ease-out;
|
|
38
|
+
|
|
39
|
+
&:hover:not([aria-selected=true]) {
|
|
40
|
+
padding-bottom: 12px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// the nudge on hover is decoration rather than a state worth keeping, so under reduced motion the tab neither moves nor animates
|
|
44
|
+
@media (prefers-reduced-motion: reduce) {
|
|
45
|
+
transition: none;
|
|
46
|
+
|
|
47
|
+
&:hover:not([aria-selected=true]) {
|
|
48
|
+
padding-bottom: 9px; // the padding the tab has when it is not hovered
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// the selected tab is part of the panel: same fill, and no border between the two
|
|
53
|
+
&[aria-selected=true] {
|
|
54
|
+
background-image: none;
|
|
55
|
+
background-color: var(--semanticFormsFormSubBgColor);
|
|
56
|
+
padding-bottom: 12px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// matches the highlight the inputs use, drawn inside so it is never clipped
|
|
60
|
+
&:focus-visible {
|
|
61
|
+
outline: none;
|
|
62
|
+
box-shadow: inset 0 0 0 2px var(--semanticFormsFocusColor);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// the border facing the panel is left transparent rather than painted in the fill colour so that the fill itself, which reaches under the border, is what covers the panel's border. that keeps the join working whatever the fill happens to be
|
|
67
|
+
&:not(.vertical) button[role=tab][aria-selected=true] {
|
|
68
|
+
border-bottom-color: transparent;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// the panel is a fieldset already, so it only needs joining to the strip above it. only a child of the group is a panel, which is the same set the enhancement builds tabs from, so a fieldset the author nested inside a panel keeps its own corners rather than being squared off against a strip it has nothing to do with
|
|
72
|
+
> fieldset {
|
|
73
|
+
margin: 0;
|
|
74
|
+
border-top-left-radius: 0;
|
|
75
|
+
border-top-right-radius: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// the fieldset rules set a display, which the hidden attribute cannot override on its own
|
|
79
|
+
fieldset[hidden] {
|
|
80
|
+
display: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// a vertical group puts the strip in a column down the start side of the panels
|
|
84
|
+
&.vertical {
|
|
85
|
+
flex-direction: row;
|
|
86
|
+
align-items: stretch;
|
|
87
|
+
|
|
88
|
+
.tabList {
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
flex-wrap: nowrap;
|
|
91
|
+
align-items: stretch;
|
|
92
|
+
flex: none;
|
|
93
|
+
max-width: 40%;
|
|
94
|
+
|
|
95
|
+
// the selected tab sits over the panel's start border to join the two together
|
|
96
|
+
margin-bottom: 0;
|
|
97
|
+
margin-inline-end: -1px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
button[role=tab] {
|
|
101
|
+
text-align: start;
|
|
102
|
+
border-radius: 0;
|
|
103
|
+
border-start-start-radius: var(--semanticFormsBorderRadius);
|
|
104
|
+
border-end-start-radius: var(--semanticFormsBorderRadius);
|
|
105
|
+
|
|
106
|
+
// an unselected tab is a flat fill halfway between the two button gradient colours
|
|
107
|
+
background-image: none;
|
|
108
|
+
background-color: color-mix(in srgb, var(--semanticFormsButtonGradientLight), var(--semanticFormsButtonGradientDark));
|
|
109
|
+
|
|
110
|
+
// an unselected tab is set in from the start edge and the selected one reaches it, the same way the horizontal strip raises the selected tab
|
|
111
|
+
//
|
|
112
|
+
// a tab reaching the edge takes the inset into its padding, so its margin and padding always add up to the same and the strip, as wide as its widest tab, keeps its width
|
|
113
|
+
margin-inline-start: 3px;
|
|
114
|
+
padding-inline-start: 20px;
|
|
115
|
+
transition: margin-inline-start 120ms ease-out, padding-inline-start 120ms ease-out;
|
|
116
|
+
|
|
117
|
+
&:hover:not([aria-selected=true]) {
|
|
118
|
+
padding-bottom: 9px;
|
|
119
|
+
margin-inline-start: 0;
|
|
120
|
+
padding-inline-start: 23px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@media (prefers-reduced-motion: reduce) {
|
|
124
|
+
transition: none;
|
|
125
|
+
|
|
126
|
+
&:hover:not([aria-selected=true]) {
|
|
127
|
+
margin-inline-start: 3px;
|
|
128
|
+
padding-inline-start: 20px;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&[aria-selected=true] {
|
|
133
|
+
padding-bottom: 9px;
|
|
134
|
+
margin-inline-start: 0;
|
|
135
|
+
padding-inline-start: 23px;
|
|
136
|
+
background-color: var(--semanticFormsFormSubBgColor);
|
|
137
|
+
|
|
138
|
+
// no end border, so the top and bottom borders run straight to the tab's end with no corner joint to lighten them. the fill stays out from under those borders so it cannot lighten them where they cross the panel's border either. the border's pixel goes to the padding, keeping the tab as wide
|
|
139
|
+
border-inline-end-width: 0;
|
|
140
|
+
padding-inline-end: 21px;
|
|
141
|
+
background-clip: padding-box;
|
|
142
|
+
|
|
143
|
+
// painted above the panel with a pixel of its fill past its end, between its top and bottom borders, so the fill still covers the panel's start border when the strip's width is fractional and the browser snaps the two to different device pixels
|
|
144
|
+
position: relative;
|
|
145
|
+
z-index: 1;
|
|
146
|
+
--semanticFormsTabJoin: 2px 0 0 -1px var(--semanticFormsFormSubBgColor);
|
|
147
|
+
box-shadow: var(--semanticFormsTabJoin);
|
|
148
|
+
|
|
149
|
+
&:dir(rtl) {
|
|
150
|
+
--semanticFormsTabJoin: -2px 0 0 -1px var(--semanticFormsFormSubBgColor);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
&:focus-visible {
|
|
154
|
+
box-shadow: inset 0 0 0 2px var(--semanticFormsFocusColor), var(--semanticFormsTabJoin);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
> fieldset {
|
|
160
|
+
flex: 1;
|
|
161
|
+
min-width: 0;
|
|
162
|
+
border-radius: var(--semanticFormsBorderRadius);
|
|
163
|
+
border-start-start-radius: 0;
|
|
164
|
+
border-end-start-radius: 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// inside a fieldset the panels are nested fieldsets, so they take the darkened nested treatment. the strip has to follow them or the selected tab reads as a different surface from the panel it is joined to
|
|
170
|
+
fieldset .tabs.semanticFormsTabsActive button[role=tab] {
|
|
171
|
+
border: var(--semanticFormsNestedFieldsetBorder);
|
|
172
|
+
|
|
173
|
+
&[aria-selected=true] {
|
|
174
|
+
// the nested fill is translucent, and a translucent fill cannot hide the panel's top border underneath it, which is what leaves a line across the bottom of the selected tab. so the same colour is rebuilt opaquely here: the tint painted as a layer over the surface the panel sits on comes out at the panel's exact colour, and covers
|
|
175
|
+
background-color: var(--semanticFormsFormSubBgColor);
|
|
176
|
+
background-image: linear-gradient(var(--semanticFormsNestedFieldsetBgColor), var(--semanticFormsNestedFieldsetBgColor));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// the strip of fill past a selected vertical tab's end is rebuilt the same way, as the tint layered over the surface
|
|
181
|
+
fieldset .tabs.semanticFormsTabsActive.vertical button[role=tab][aria-selected=true] {
|
|
182
|
+
--semanticFormsTabJoin: 2px 0 0 -1px var(--semanticFormsNestedFieldsetBgColor), 2px 0 0 -1px var(--semanticFormsFormSubBgColor);
|
|
183
|
+
|
|
184
|
+
&:dir(rtl) {
|
|
185
|
+
--semanticFormsTabJoin: -2px 0 0 -1px var(--semanticFormsNestedFieldsetBgColor), -2px 0 0 -1px var(--semanticFormsFormSubBgColor);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|