semantic-forms 2.1.1 → 3.0.0

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/README.md CHANGED
@@ -22,6 +22,8 @@ Apply the `semanticForms` class to your `<form>` elements:
22
22
 
23
23
  Then the CSS/JS enhancements to your forms will apply automatically.
24
24
 
25
+ If you add new forms to the DOM after the initial initialization, you can call the global `semanticForms` function to initialize new forms that have been added to the DOM since the initial initialization.
26
+
25
27
  See `semanticForms.html` or the [live demo](https://kethinov.github.io/semanticforms/semanticForms.html) for a complete pattern library with examples of all UI patterns.
26
28
 
27
29
  # Features
@@ -56,6 +58,8 @@ The float label input pattern is notoriously difficult to implement in a fashion
56
58
 
57
59
  If you would like to manipulate the size of the area on the input field reserved for the click event of the clear field, apply one or both of the following `data-` attributes to your form.
58
60
 
61
+ If you want to double the width of the input field (on screens with the extra space), add a `x2` class to the `dd` element.
62
+
59
63
  Adjust the horizontal offset of the clear field's click event click area (the default is 21):
60
64
 
61
65
  ```html
@@ -64,7 +68,7 @@ Adjust the horizontal offset of the clear field's click event click area (the de
64
68
  </form>
65
69
  ```
66
70
 
67
- Adjust the vertical offset of the clear field"s click event click area (the default is 5):
71
+ Adjust the vertical offset of the clear field's click event click area (the default is 5):
68
72
 
69
73
  ```html
70
74
  <form class="semanticForms" data-clearfield-vertical-offset="5">
@@ -144,7 +148,7 @@ Checkboxes and radio buttons need to follow the following markup structure:
144
148
 
145
149
  - Custom-styled select boxes with a custom drawn arrow graphic driven by SVG embedded in the CSS.
146
150
  - Custom-styled submit buttons to match the aesthetic of the custom-styled forms.
147
- - Responsive: on wide screens, the forms split into two columns. On smaller screens, they collapse to a single column.
151
+ - Responsive: on wide screens, the forms split into multiple columns. On smaller screens, they collapse to a single column.
148
152
  - Low-flow mode that displays on old browsers, JS-disabled browsers, or can be activated manually by adding the `lowFlow` class to your `<form>` element. The low-flow mode reverts the float label pattern to traditional labels and collapses the forms to single column mode, but preserves the other visual design enhancements driven purely by CSS.
149
153
 
150
154
  See `semanticForms.html` or the [live demo](https://kethinov.github.io/semanticforms/semanticForms.html) for more examples.
@@ -152,8 +156,8 @@ See `semanticForms.html` or the [live demo](https://kethinov.github.io/semanticf
152
156
  # Contributing
153
157
 
154
158
  - Fork/clone this repo.
155
- - `npm i`
156
- - Make your changes. If you want to alter the CSS, do the changes in `semanticForms.less`.
159
+ - `npm ci`
160
+ - Make your changes. If you want to alter the CSS, do the changes in the `.less` files.
157
161
  - `npm run build`. The build step compiles the LESS file into CSS.
158
162
  - Test your changes by opening `semanticForms.html` in your browser.
159
163
  - Commit, push, open pull request.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "semantic-forms",
3
3
  "description": "Semantic Forms",
4
4
  "author": "Eric Newport <kethinov@gmail.com>",
5
- "version": "2.1.1",
5
+ "version": "3.0.0",
6
6
  "files": [
7
7
  "semanticForms.css",
8
8
  "semanticForms.js",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {},
18
18
  "devDependencies": {
19
19
  "less": "4.1.3",
20
- "standard": "17.0.0"
20
+ "standard": "17.1.0"
21
21
  },
22
22
  "scripts": {
23
23
  "test": "echo \"TODO: tests\"",
package/semanticForms.css CHANGED
@@ -1,12 +1,5 @@
1
1
  .semanticForms {
2
2
  font-family: sans-serif;
3
- /*
4
- TODO: still needed?
5
- input:not([type='submit']):not([type='reset']):not([type='image']):not([type=checkbox]):not([type=radio]) {
6
- width: 270px;
7
- padding-right: 0;
8
- }
9
- */
10
3
  }
11
4
  .semanticForms input:not([type='submit']):not([type='reset']):not([type='image']):not([type=checkbox]):not([type=radio]):not([type=color]),
12
5
  .semanticForms select,
@@ -167,7 +160,6 @@
167
160
  }
168
161
  .semanticForms .floatLabelForm {
169
162
  margin: 0 auto;
170
- width: 292px;
171
163
  }
172
164
  .semanticForms .floatLabelForm input[disabled] {
173
165
  opacity: 0.5;
@@ -180,9 +172,6 @@
180
172
  float: left;
181
173
  margin: 0 10px 0 10px;
182
174
  }
183
- .semanticForms .floatLabelForm dd:nth-child(4n+2) {
184
- clear: both;
185
- }
186
175
  .semanticForms .floatLabelForm dt:not(.checkboxes):not(.radios) {
187
176
  font-size: 1px;
188
177
  text-indent: 100%;
@@ -198,7 +187,7 @@
198
187
  .semanticForms .floatLabelForm .checkboxes ul,
199
188
  .semanticForms .floatLabelForm .radios ul {
200
189
  margin: 3px 20px 0 0;
201
- width: 267px;
190
+ width: 262px;
202
191
  padding-left: 10px;
203
192
  }
204
193
  .semanticForms .floatLabelForm label.floatLabelFormAnimatedLabel {
@@ -314,7 +303,7 @@
314
303
  .semanticForms menu button {
315
304
  float: none;
316
305
  clear: none;
317
- margin: 0 0 25px 0;
306
+ margin: 0;
318
307
  }
319
308
  @media (min-width: 700px) {
320
309
  .semanticForms .floatLabelForm {
@@ -337,6 +326,27 @@
337
326
  .semanticForms fieldset :last-child {
338
327
  margin-right: 0;
339
328
  }
329
+ .semanticForms .x2 input:not([type='submit']):not([type='reset']):not([type='image']):not([type=checkbox]):not([type=radio]):not([type=color]),
330
+ .semanticForms .x2 select,
331
+ .semanticForms .x2 textarea {
332
+ width: 562px;
333
+ }
334
+ .semanticForms .x2 input[type=color] {
335
+ width: 604px;
336
+ }
337
+ .semanticForms .x2 input[type=range] {
338
+ width: 560px !important;
339
+ }
340
+ .semanticForms .x2 select {
341
+ width: 604px;
342
+ }
343
+ .semanticForms .x2.checkboxes ul,
344
+ .semanticForms .x2.radios ul {
345
+ width: 574px;
346
+ }
347
+ .semanticForms .x2 label.floatLabelFormAnimatedLabel {
348
+ width: 375px;
349
+ }
340
350
  }
341
351
  .semanticForms.lowFlow dl {
342
352
  margin: 10px 0 0 0;
package/semanticForms.js CHANGED
@@ -1,10 +1,10 @@
1
- (function () {
1
+ window.semanticForms = function () {
2
2
  // do some feature detection so none of the JS executes if the browser is too old
3
3
  if (typeof document.getElementsByClassName !== 'function' || typeof document.querySelector !== 'function' || !document.body.classList) {
4
4
  return
5
5
  }
6
6
 
7
- const forms = document.querySelectorAll('form.semanticForms')
7
+ const forms = document.querySelectorAll('form.semanticForms:not(.semanticFormsActive)')
8
8
  const fl = forms.length
9
9
  let f
10
10
  let form
@@ -28,6 +28,7 @@
28
28
 
29
29
  for (f = 0; f < fl; f++) {
30
30
  form = forms[f]
31
+ form.classList.add('semanticFormsActive')
31
32
  if (!form.classList.contains('lowFlow')) {
32
33
  clearfieldHorizontalOffset = parseInt(form.getAttribute('data-clearfield-horizontal-offset')) || 21
33
34
  clearfieldVerticalOffset = parseInt(form.getAttribute('data-clearfield-vertical-offset')) || 5
@@ -154,9 +155,10 @@
154
155
 
155
156
  function isPatternElement (e) {
156
157
  const thisEl = e.target || e
157
- if (!thisEl.classList.contains('semanticform')) {
158
+ if (!thisEl || !thisEl.classList || !thisEl.classList.contains('semanticform')) {
158
159
  return false
159
160
  }
160
161
  return true
161
162
  }
162
- })(this)
163
+ }
164
+ window.semanticForms()
@@ -1,12 +1,5 @@
1
1
  .semanticForms {
2
2
  font-family: sans-serif;
3
- /*
4
- TODO: still needed?
5
- input:not([type='submit']):not([type='reset']):not([type='image']):not([type=checkbox]):not([type=radio]) {
6
- width: 270px;
7
- padding-right: 0;
8
- }
9
- */
10
3
  }
11
4
  .semanticForms input:not([type='submit']):not([type='reset']):not([type='image']):not([type=checkbox]):not([type=radio]):not([type=color]),
12
5
  .semanticForms select,
@@ -167,7 +160,6 @@
167
160
  }
168
161
  .semanticForms .floatLabelForm {
169
162
  margin: 0 auto;
170
- width: 292px;
171
163
  }
172
164
  .semanticForms .floatLabelForm input[disabled] {
173
165
  opacity: 0.5;
@@ -180,9 +172,6 @@
180
172
  float: left;
181
173
  margin: 0 10px 0 10px;
182
174
  }
183
- .semanticForms .floatLabelForm dd:nth-child(4n+2) {
184
- clear: both;
185
- }
186
175
  .semanticForms .floatLabelForm dt:not(.checkboxes):not(.radios) {
187
176
  font-size: 1px;
188
177
  text-indent: 100%;
@@ -198,7 +187,7 @@
198
187
  .semanticForms .floatLabelForm .checkboxes ul,
199
188
  .semanticForms .floatLabelForm .radios ul {
200
189
  margin: 3px 20px 0 0;
201
- width: 267px;
190
+ width: 262px;
202
191
  padding-left: 10px;
203
192
  }
204
193
  .semanticForms .floatLabelForm label.floatLabelFormAnimatedLabel {
@@ -314,7 +303,7 @@
314
303
  .semanticForms menu button {
315
304
  float: none;
316
305
  clear: none;
317
- margin: 0 0 25px 0;
306
+ margin: 0;
318
307
  }
319
308
  @media (min-width: 700px) {
320
309
  .semanticForms .floatLabelForm {
@@ -337,6 +326,27 @@
337
326
  .semanticForms fieldset :last-child {
338
327
  margin-right: 0;
339
328
  }
329
+ .semanticForms .x2 input:not([type='submit']):not([type='reset']):not([type='image']):not([type=checkbox]):not([type=radio]):not([type=color]),
330
+ .semanticForms .x2 select,
331
+ .semanticForms .x2 textarea {
332
+ width: 562px;
333
+ }
334
+ .semanticForms .x2 input[type=color] {
335
+ width: 604px;
336
+ }
337
+ .semanticForms .x2 input[type=range] {
338
+ width: 560px !important;
339
+ }
340
+ .semanticForms .x2 select {
341
+ width: 604px;
342
+ }
343
+ .semanticForms .x2.checkboxes ul,
344
+ .semanticForms .x2.radios ul {
345
+ width: 574px;
346
+ }
347
+ .semanticForms .x2 label.floatLabelFormAnimatedLabel {
348
+ width: 375px;
349
+ }
340
350
  }
341
351
  .semanticForms.lowFlow dl {
342
352
  margin: 10px 0 0 0;
@@ -69,7 +69,6 @@
69
69
  margin: 0;
70
70
  }
71
71
 
72
-
73
72
  // clear fields
74
73
  input:not([type='submit']):not([type='reset']):not([type=checkbox]):not([type=radio]),
75
74
  textarea {
@@ -83,14 +82,6 @@
83
82
  background-position: right -12px center;
84
83
  }
85
84
 
86
- /*
87
- TODO: still needed?
88
- input:not([type='submit']):not([type='reset']):not([type='image']):not([type=checkbox]):not([type=radio]) {
89
- width: 270px;
90
- padding-right: 0;
91
- }
92
- */
93
-
94
85
  textarea {
95
86
  background-position: right -12px top 10px;
96
87
  height: 100px;
@@ -184,7 +175,6 @@
184
175
  background-image: linear-gradient(to bottom, @borderColor 0%, @formBackgroundColor 100%);
185
176
  }
186
177
 
187
-
188
178
  // custom select box design
189
179
  select {
190
180
  background-image: none;
@@ -199,7 +189,6 @@
199
189
  appearance: none;
200
190
  }
201
191
 
202
-
203
192
  // float label forms
204
193
  label.floatLabelFormAnimatedLabel, input:not([type=checkbox]):not([type=radio]), select, textarea, section {
205
194
  transition: all 0.2s;
@@ -208,7 +197,6 @@
208
197
 
209
198
  .floatLabelForm {
210
199
  margin: 0 auto;
211
- width: 292px;
212
200
 
213
201
  input[disabled] {
214
202
  opacity: 0.5;
@@ -225,10 +213,6 @@
225
213
  margin: 0 10px 0 10px;
226
214
  }
227
215
 
228
- dd:nth-child(4n+2) {
229
- clear: both;
230
- }
231
-
232
216
  dt:not(.checkboxes):not(.radios) {
233
217
  font-size: 1px;
234
218
  text-indent: 100%;
@@ -246,7 +230,7 @@
246
230
  .checkboxes ul,
247
231
  .radios ul {
248
232
  margin: 3px 20px 0 0;
249
- width: 267px;
233
+ width: 262px;
250
234
  padding-left: 10px;
251
235
  }
252
236
 
@@ -388,11 +372,10 @@
388
372
  button {
389
373
  float: none;
390
374
  clear: none;
391
- margin: 0 0 25px 0;
375
+ margin: 0;
392
376
  }
393
377
  }
394
378
 
395
-
396
379
  // side-by-side pattern on large screens
397
380
  @media (min-width: 700px) {
398
381
  .floatLabelForm {
@@ -418,6 +401,43 @@
418
401
  margin-right: 0;
419
402
  }
420
403
  }
404
+
405
+ .x2 {
406
+ input:not([type='submit']):not([type='reset']):not([type='image']):not([type=checkbox]):not([type=radio]):not([type=color]),
407
+ select,
408
+ textarea {
409
+ width: 562px;
410
+ }
411
+ }
412
+
413
+ .x2 {
414
+ input[type=color] {
415
+ width: 604px;
416
+ }
417
+ }
418
+
419
+ .x2 {
420
+ input[type=range] {
421
+ width: 560px !important;
422
+ }
423
+ }
424
+
425
+ .x2 {
426
+ select {
427
+ width: 604px;
428
+ }
429
+ }
430
+
431
+ .x2.checkboxes ul,
432
+ .x2.radios ul {
433
+ width: 574px;
434
+ }
435
+
436
+ .x2 {
437
+ label.floatLabelFormAnimatedLabel {
438
+ width: 375px;
439
+ }
440
+ }
421
441
  }
422
442
  }
423
443