@jamesrock/rockjs 1.27.0 → 1.28.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.
Files changed (2) hide show
  1. package/index.js +9 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -167,15 +167,15 @@ export const createLabel = (label = '{label}', id = '{id}', className) => {
167
167
  return node;
168
168
  };
169
169
 
170
- export const createToggle = (options, id, defaultValue) => {
171
- const node = createNode('div', 'toggle');
172
- options.forEach((option) => {
173
- const optionNode = createNode('div', 'toggle-item');
174
- const radio = createRadio(option, id, `${option}-${id}`, option===defaultValue);
175
- const label = createLabel(option, radio.id);
176
- optionNode.append(radio);
177
- optionNode.append(label);
178
- node.append(optionNode);
170
+ const makeToggle = (options, name, defaultValue, className = 'toggle') => {
171
+ const node = createNode('div', className);
172
+ options.forEach(([label, value, optionClassName]) => {
173
+ const optionNode = createNode('div', 'toggle-item');
174
+ const radioNode = createRadio(value, name, `${name}-${value}`, value===defaultValue);
175
+ const labelNode = createLabel(label, radioNode.id, optionClassName);
176
+ optionNode.appendChild(radioNode);
177
+ optionNode.appendChild(labelNode);
178
+ node.appendChild(optionNode);
179
179
  });
180
180
  return node;
181
181
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesrock/rockjs",
3
- "version": "1.27.0",
3
+ "version": "1.28.0",
4
4
  "description": "utility bliss",
5
5
  "license": "ISC",
6
6
  "author": "James Rock",