@jamesrock/rockjs 1.11.0 → 1.13.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 +25 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -26,6 +26,12 @@ export const getDateTimeString = (type = 'short') => `${getDateString(type)} ${g
26
26
  export const isValidKey = (key, options) => options.includes(key);
27
27
  export const makeArray = (length, mapper = (a, i) => i) => Array.from({length}, mapper);
28
28
 
29
+ export const empty = (node) => {
30
+ while(node.firstChild) {
31
+ node.removeChild(node.firstChild);
32
+ };
33
+ };
34
+
29
35
  export const shuffle = (a) => {
30
36
  for(let i = 0; i < a.length; i++) {
31
37
  const b = Math.floor(Math.random() * a.length);
@@ -288,8 +294,8 @@ export class BrickMaker extends DisplayObject {
288
294
 
289
295
  const node = this.node = createNode('div', 'brick-maker');
290
296
  const bits = this.bits = [];
291
-
292
- node.style.setProperty('--color', this.color);
297
+
298
+ this.setColor(color);
293
299
  node.style.width = node.style.height = `${scale*size + (gap*(size-1))}px`;
294
300
  node.style.gap = `${gap}px`;
295
301
 
@@ -363,6 +369,23 @@ export class BrickMaker extends DisplayObject {
363
369
 
364
370
  return this;
365
371
 
372
+ };
373
+ clear() {
374
+
375
+ this.bits.forEach((bit) => {
376
+ bit.dataset.active = 'N';
377
+ });
378
+ this.calculate();
379
+
380
+ return this;
381
+
382
+ };
383
+ setColor(color) {
384
+
385
+ this.color = color;
386
+ this.node.style.setProperty('--color', this.color);
387
+ return this;
388
+
366
389
  };
367
390
  value = null;
368
391
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesrock/rockjs",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "utility bliss",
5
5
  "license": "ISC",
6
6
  "author": "James Rock",