semantic-forms 3.0.1 → 3.0.2

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
@@ -111,7 +111,21 @@ Driven by flexbox to intelligently align the buttons based on how many are in th
111
111
  ## Checkboxes and radio buttons
112
112
 
113
113
  Checkboxes and radio buttons need to follow the following markup structure:
114
- ### Checkboxes
114
+
115
+ ### A single checkbox
116
+
117
+ Not too different than other inputs:
118
+
119
+ ```html
120
+ <form class="semanticForms">
121
+ <dl>
122
+ <dt><label for="checkbox">Single checkbox</label></dt>
123
+ <dd><input id="checkbox" name="checkbox" type="checkbox"></dd>
124
+ </dl>
125
+ </form>
126
+ ```
127
+
128
+ ### Checkbox group
115
129
 
116
130
  ```html
117
131
  <form class="semanticForms">
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": "3.0.1",
5
+ "version": "3.0.2",
6
6
  "files": [
7
7
  "semanticForms.css",
8
8
  "semanticForms.js",
package/semanticForms.css CHANGED
@@ -202,6 +202,19 @@
202
202
  transform-origin: left bottom;
203
203
  transform: translate(0, 38px) scale(1.5);
204
204
  }
205
+ .semanticForms .floatLabelForm dd:not(.checkboxes):not(.radios).singleCheckbox {
206
+ width: 292px;
207
+ display: flex;
208
+ flex-direction: row-reverse;
209
+ align-items: flex-start;
210
+ justify-content: left;
211
+ }
212
+ .semanticForms .floatLabelForm dd:not(.checkboxes):not(.radios).singleCheckbox label {
213
+ margin-top: 10px;
214
+ }
215
+ .semanticForms .floatLabelForm dd:not(.checkboxes):not(.radios).singleCheckbox input {
216
+ margin: 10px 10px 0 0;
217
+ }
205
218
  .semanticForms .floatLabelForm ::placeholder {
206
219
  opacity: 0;
207
220
  transition: inherit;
package/semanticForms.js CHANGED
@@ -49,7 +49,7 @@ window.semanticForms = function () {
49
49
  if (!dl.classList.contains('floatLabelForm')) {
50
50
  dl.classList.add('floatLabelForm')
51
51
  }
52
- if (type === 'checkbox' || type === 'radio') {
52
+ if (input.parentNode.parentNode.id && (type === 'checkbox' || type === 'radio')) {
53
53
  label = document.querySelector('label[data-for=' + input.parentNode.parentNode.id + ']')
54
54
  } else {
55
55
  label = document.querySelector('label[for=' + input.id + ']')
@@ -63,6 +63,11 @@ window.semanticForms = function () {
63
63
  if (dl.firstChild.nodeName !== 'LABEL') {
64
64
  newLabel = document.createElement('label')
65
65
  newLabel.className = 'floatLabelFormAnimatedLabel'
66
+ if (type === 'checkbox' && input.parentNode.nodeName === 'DD') {
67
+ newLabel.setAttribute('for', input.id)
68
+ input.parentNode.classList.add('singleCheckbox')
69
+ newLabel.className = ''
70
+ }
66
71
  newLabel.innerHTML = labelHTML
67
72
  dl.insertBefore(newLabel, dl.firstChild)
68
73
  }
@@ -202,6 +202,19 @@
202
202
  transform-origin: left bottom;
203
203
  transform: translate(0, 38px) scale(1.5);
204
204
  }
205
+ .semanticForms .floatLabelForm dd:not(.checkboxes):not(.radios).singleCheckbox {
206
+ width: 292px;
207
+ display: flex;
208
+ flex-direction: row-reverse;
209
+ align-items: flex-start;
210
+ justify-content: left;
211
+ }
212
+ .semanticForms .floatLabelForm dd:not(.checkboxes):not(.radios).singleCheckbox label {
213
+ margin-top: 10px;
214
+ }
215
+ .semanticForms .floatLabelForm dd:not(.checkboxes):not(.radios).singleCheckbox input {
216
+ margin: 10px 10px 0 0;
217
+ }
205
218
  .semanticForms .floatLabelForm ::placeholder {
206
219
  opacity: 0;
207
220
  transition: inherit;
@@ -247,6 +247,22 @@
247
247
  transform: translate(0, 38px) scale(1.5);
248
248
  }
249
249
 
250
+ dd:not(.checkboxes):not(.radios).singleCheckbox {
251
+ width: 292px;
252
+ display: flex;
253
+ flex-direction: row-reverse;
254
+ align-items: flex-start;
255
+ justify-content: left;
256
+
257
+ label {
258
+ margin-top: 10px;
259
+ }
260
+
261
+ input {
262
+ margin: 10px 10px 0 0;
263
+ }
264
+ }
265
+
250
266
  // hide placeholder content until the input is focused
251
267
  ::placeholder {
252
268
  opacity: 0;