@stanko/ctrls 0.4.4 → 0.4.6
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 +8 -7
- package/dist/ctrls/index.d.ts +0 -1
- package/dist/ctrls/index.js +13 -21
- package/dist/ctrls.css +56 -23
- package/dist/ctrls.css.map +1 -1
- package/dist/utils/get-drawer.d.ts +1 -0
- package/dist/utils/get-drawer.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,16 +4,16 @@ Minimal library for controlling parameters, designed specifically for algorithmi
|
|
|
4
4
|
|
|
5
5
|
[](https://muffinman.io/ctrls/)
|
|
6
6
|
|
|
7
|
-
## Made for algorithmic art
|
|
7
|
+
## Made for algorithmic/generative art
|
|
8
8
|
|
|
9
|
-
I built Ctrls for my [
|
|
9
|
+
I built Ctrls for my [art projects](https://muffinman.io/art/). By default, the state is saved in the URL, which lets you navigate history and share links easily. Along with standard components like checkboxes and ranges, it includes two especially useful for generative work: RNG seed and easing. These not only let you adjust parameters but also expose functions (rng and easing) you can call directly.
|
|
10
10
|
|
|
11
|
-
Play with the live example above or check
|
|
11
|
+
Play with the live example above or check older versions I used for [Space Invaders generator](https://muffinman.io/invaders/) and [Moon Phases](http://muffinman.io/moon/).
|
|
12
12
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
15
|
- Minimal API
|
|
16
|
-
-
|
|
16
|
+
- Eight components : RNG seed, easing, boolean, radio, range, dual range, file and custom HTML
|
|
17
17
|
- Fully typed, including dynamic typings for controlled properties
|
|
18
18
|
- Light and dark themes included, theming via CSS variables
|
|
19
19
|
|
|
@@ -466,7 +466,7 @@ Check [the source file](https://github.com/Stanko/ctrls/blob/dev/src/scss/_ctrls
|
|
|
466
466
|
|
|
467
467
|
## Why?
|
|
468
468
|
|
|
469
|
-
You might ask why I made another library when [dat.GUI](https://github.com/dataarts/dat.gui) and [TweakPane](https://tweakpane.github.io/docs/) already exist. Both target general use cases with extensive options and elaborate APIs, while I wanted something smaller and easier to adapt for [my
|
|
469
|
+
You might ask why I made another library when [dat.GUI](https://github.com/dataarts/dat.gui) and [TweakPane](https://tweakpane.github.io/docs/) already exist. Both target general use cases with extensive options and elaborate APIs, while I wanted something smaller and easier to adapt for [my generative drawings](https://muffinman.io/art/).
|
|
470
470
|
|
|
471
471
|
I first hacked together a crude library with no plans to release it. Over time I polished it, ported it to TypeScript, and realized it could be useful to others. The code is solid, though I would love to add a few more features.
|
|
472
472
|
|
|
@@ -481,11 +481,12 @@ Thank you for stopping by! If you end up using Ctrls, please let me know, I woul
|
|
|
481
481
|
## TODO
|
|
482
482
|
|
|
483
483
|
* [ ] Add `add/removeEventListener` instead of direct update of `onInput` and `onChange`
|
|
484
|
+
* [ ] Check if `onInput` is triggered when it should
|
|
484
485
|
* [ ] Allow users to pass a custom PRNG lib
|
|
485
486
|
* [ ] Hash storage - check if there is an instance using hash storage already
|
|
486
487
|
* [ ] Storage - local storage
|
|
487
|
-
* [
|
|
488
|
-
* [
|
|
488
|
+
* [*] Collapsing animation for the main element and groups
|
|
489
|
+
* [x] Use dom helpers everywhere
|
|
489
490
|
* [x] `toHtmlId(this.name)` => `toHtmlId(this.id)`
|
|
490
491
|
* [x] Add `name` and `id` to inputs
|
|
491
492
|
* [x] TypeDef bug - easing presets should be optional
|
package/dist/ctrls/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export declare class Ctrls<Configs extends readonly ConfigItem[]> {
|
|
|
10
10
|
constructor(configs: Configs, options?: ControlsOptions);
|
|
11
11
|
processControls: (configs: Configs) => HTMLElement[];
|
|
12
12
|
registerControl: (config: TypedControlConfig, onChangeControlHandler: (control: CtrlComponent) => void, onInputControlHandler: (control: CtrlComponent) => void, group?: string) => CtrlComponent;
|
|
13
|
-
toggleVisibility: () => void;
|
|
14
13
|
addHashListeners: () => void;
|
|
15
14
|
getHash: () => string;
|
|
16
15
|
setHash: () => void;
|
package/dist/ctrls/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import Alea from "../utils/alea";
|
|
|
12
12
|
import { chevronUpIcon, diceIcon } from "../utils/icons";
|
|
13
13
|
import { getHTMLControlElement } from "./ctrl-html";
|
|
14
14
|
import { dom } from "../utils/dom";
|
|
15
|
+
import { getDrawer } from "../utils/get-drawer";
|
|
15
16
|
const controlMap = {
|
|
16
17
|
boolean: BooleanCtrl,
|
|
17
18
|
range: RangeCtrl,
|
|
@@ -46,20 +47,15 @@ export class Ctrls {
|
|
|
46
47
|
const groupTitle = dom.button("ctrls__group-title", {
|
|
47
48
|
innerHTML: (config.label || toSpaceCase(config.name)) + chevronUpIcon,
|
|
48
49
|
});
|
|
49
|
-
groupTitle.addEventListener("click", () => {
|
|
50
|
-
groupTitle.parentElement?.classList.toggle("ctrls__group--hidden");
|
|
51
|
-
});
|
|
52
50
|
const controlsElements = config.controls.map((itemConfig) => {
|
|
53
51
|
const control = this.registerControl(itemConfig, onChangeControlHandler, onInputControlHandler, toCamelCase(config.name));
|
|
54
52
|
return control.element;
|
|
55
53
|
});
|
|
54
|
+
const groupControls = getDrawer("ctrls__group-controls", controlsElements, groupTitle, config.isCollapsed);
|
|
56
55
|
// Create group element
|
|
57
56
|
const groupElement = dom.div("ctrls__group", {
|
|
58
|
-
children: [groupTitle,
|
|
57
|
+
children: [groupTitle, groupControls],
|
|
59
58
|
});
|
|
60
|
-
if (config.isCollapsed) {
|
|
61
|
-
groupElement.classList.add("ctrls__group--hidden");
|
|
62
|
-
}
|
|
63
59
|
// Add the group element
|
|
64
60
|
elements.push(groupElement);
|
|
65
61
|
}
|
|
@@ -94,9 +90,6 @@ export class Ctrls {
|
|
|
94
90
|
this.controls.push(control);
|
|
95
91
|
return control;
|
|
96
92
|
};
|
|
97
|
-
this.toggleVisibility = () => {
|
|
98
|
-
this.element.classList.toggle("ctrls--hidden");
|
|
99
|
-
};
|
|
100
93
|
this.addHashListeners = () => {
|
|
101
94
|
window.addEventListener("hashchange", this.updateFromHash);
|
|
102
95
|
// Update all inputs using initial values from the hash
|
|
@@ -172,25 +165,24 @@ export class Ctrls {
|
|
|
172
165
|
...options,
|
|
173
166
|
};
|
|
174
167
|
// Title
|
|
175
|
-
let titleButton =
|
|
176
|
-
|
|
177
|
-
titleButton = dom.button("ctrls__title", {
|
|
168
|
+
let titleButton = this.options.title
|
|
169
|
+
? dom.button("ctrls__title", {
|
|
178
170
|
innerHTML: this.options.title + chevronUpIcon,
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
}
|
|
171
|
+
})
|
|
172
|
+
: null;
|
|
182
173
|
// Randomize button
|
|
183
|
-
let
|
|
174
|
+
let randomizeRow = null;
|
|
184
175
|
if (this.options.showRandomizeButton) {
|
|
185
|
-
randomizeButton = dom.button("ctrls__randomize ctrls__btn ctrls__btn--lg", { innerHTML: `Randomize ${diceIcon}` });
|
|
176
|
+
const randomizeButton = dom.button("ctrls__randomize ctrls__btn ctrls__btn--lg", { innerHTML: `Randomize ${diceIcon}` });
|
|
186
177
|
randomizeButton.addEventListener("click", this.randomize);
|
|
178
|
+
randomizeRow = dom.div("ctrls__control-no-label", {
|
|
179
|
+
children: [randomizeButton],
|
|
180
|
+
});
|
|
187
181
|
}
|
|
188
182
|
// Control elements
|
|
189
183
|
const controlElements = this.processControls(configs);
|
|
190
184
|
// Controls wrapper
|
|
191
|
-
const controlsContainer =
|
|
192
|
-
children: [...controlElements, randomizeButton],
|
|
193
|
-
});
|
|
185
|
+
const controlsContainer = getDrawer("ctrls__controls", [...controlElements, randomizeRow], titleButton);
|
|
194
186
|
// Main element
|
|
195
187
|
this.element = dom.div(`ctrls ctrls--${this.options.theme}-theme`, {
|
|
196
188
|
children: [titleButton, controlsContainer],
|
package/dist/ctrls.css
CHANGED
|
@@ -346,58 +346,92 @@
|
|
|
346
346
|
width: 1rem;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
.
|
|
350
|
-
|
|
349
|
+
.ctrls__controls-inner {
|
|
350
|
+
display: grid;
|
|
351
|
+
gap: 0.5rem;
|
|
352
|
+
overflow: auto;
|
|
353
|
+
scrollbar-width: thin;
|
|
354
|
+
scrollbar-color: var(--ctrls-scrollbar-thumb-bg) transparent;
|
|
355
|
+
}
|
|
356
|
+
.ctrls__controls-inner > *:last-child:not(:first-child) {
|
|
357
|
+
margin-bottom: 0.5rem;
|
|
351
358
|
}
|
|
352
359
|
|
|
353
|
-
.
|
|
354
|
-
|
|
355
|
-
|
|
360
|
+
.ctrls__drawer {
|
|
361
|
+
display: none;
|
|
362
|
+
align-items: flex-start;
|
|
363
|
+
grid-template-rows: 0fr;
|
|
364
|
+
transition: grid-template-rows 500ms, opacity 500ms, display 500ms;
|
|
365
|
+
transition-behavior: allow-discrete;
|
|
366
|
+
overflow: hidden;
|
|
367
|
+
opacity: 0;
|
|
356
368
|
}
|
|
357
369
|
|
|
358
|
-
.
|
|
359
|
-
overflow: auto;
|
|
370
|
+
.ctrls__drawer--expanded {
|
|
360
371
|
display: grid;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
scrollbar-color: var(--ctrls-scrollbar-thumb-bg) transparent;
|
|
372
|
+
grid-template-rows: 1fr;
|
|
373
|
+
opacity: 1;
|
|
364
374
|
}
|
|
365
375
|
|
|
366
|
-
|
|
367
|
-
|
|
376
|
+
@starting-style {
|
|
377
|
+
.ctrls__drawer--ready.ctrls__drawer--expanded {
|
|
378
|
+
grid-template-rows: 0fr;
|
|
379
|
+
opacity: 0;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
.ctrls__drawer-inner {
|
|
383
|
+
overflow: hidden;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.ctrls__drawer-toggle--collapsed svg {
|
|
387
|
+
transform: rotate(180deg);
|
|
368
388
|
}
|
|
369
389
|
|
|
370
390
|
.ctrls__group {
|
|
371
|
-
margin: 0.
|
|
391
|
+
margin-inline: 0.5rem;
|
|
372
392
|
border: 1px solid var(--ctrls-border);
|
|
373
393
|
border-radius: var(--ctrls-radius);
|
|
374
394
|
overflow: hidden;
|
|
375
395
|
}
|
|
396
|
+
.ctrls__group:only-child {
|
|
397
|
+
margin-block: 0.5rem;
|
|
398
|
+
}
|
|
376
399
|
|
|
377
400
|
.ctrls__group .ctrls__control {
|
|
378
401
|
grid-template-columns: calc(var(--ctrls-label-width) - 0.5rem) minmax(0, 1fr);
|
|
379
402
|
}
|
|
380
403
|
|
|
381
|
-
.ctrls__group
|
|
382
|
-
|
|
404
|
+
.ctrls__group-controls-inner {
|
|
405
|
+
display: grid;
|
|
406
|
+
gap: 0.5rem;
|
|
383
407
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
408
|
+
.ctrls__group-controls-inner > *:first-child {
|
|
409
|
+
margin-top: 0.25rem;
|
|
410
|
+
}
|
|
411
|
+
.ctrls__group-controls-inner > *:last-child {
|
|
412
|
+
margin-bottom: 0.25rem;
|
|
387
413
|
}
|
|
388
414
|
|
|
389
415
|
.ctrls__control {
|
|
390
|
-
padding: 0
|
|
416
|
+
padding: 0 0.5rem;
|
|
391
417
|
display: grid;
|
|
392
418
|
grid-template-columns: var(--ctrls-label-width) minmax(0, 1fr);
|
|
393
419
|
align-items: center;
|
|
394
420
|
}
|
|
395
421
|
.ctrls__control:hover {
|
|
396
422
|
background: var(--ctrls-hover-bg);
|
|
423
|
+
box-shadow: 0 0 0 0.25rem var(--ctrls-hover-bg);
|
|
397
424
|
}
|
|
398
425
|
.ctrls__control:hover .ctrls__control-label {
|
|
399
426
|
color: var(--ctrls-theme);
|
|
400
427
|
}
|
|
428
|
+
.ctrls__control:only-child {
|
|
429
|
+
padding-block: 0.5rem;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.ctrls__control-no-label {
|
|
433
|
+
padding: 0 0.5rem 0 calc(var(--ctrls-label-width) + 0.5rem);
|
|
434
|
+
}
|
|
401
435
|
|
|
402
436
|
.ctrls__control-label {
|
|
403
437
|
color: var(--ctrls-text-muted);
|
|
@@ -446,8 +480,7 @@
|
|
|
446
480
|
}
|
|
447
481
|
|
|
448
482
|
.ctrls__btn--lg {
|
|
449
|
-
|
|
450
|
-
margin-inline-end: 0.5rem;
|
|
483
|
+
width: 100%;
|
|
451
484
|
padding: 0.5rem 1rem;
|
|
452
485
|
background: var(--ctrls-btn-bg);
|
|
453
486
|
border: 1px solid var(--ctrls-input-border);
|
|
@@ -460,7 +493,7 @@
|
|
|
460
493
|
}
|
|
461
494
|
|
|
462
495
|
.ctrls__randomize {
|
|
463
|
-
|
|
496
|
+
grid-column: 2;
|
|
464
497
|
}
|
|
465
498
|
.ctrls__randomize:focus-visible svg, .ctrls__randomize:hover svg {
|
|
466
499
|
transform: rotate(0.5turn);
|
|
@@ -776,7 +809,6 @@ label:hover .ctrls__boolean-input:not(:checked) + .ctrls__boolean-checkmark {
|
|
|
776
809
|
border: 1px solid var(--ctrls-input-border);
|
|
777
810
|
background: var(--ctrls-input-wrapper-bg);
|
|
778
811
|
border-radius: min(var(--ctrls-radius), 12px);
|
|
779
|
-
margin-bottom: 0.25rem;
|
|
780
812
|
}
|
|
781
813
|
|
|
782
814
|
.ctrls__easing {
|
|
@@ -820,6 +852,7 @@ label:hover .ctrls__boolean-input:not(:checked) + .ctrls__boolean-checkmark {
|
|
|
820
852
|
display: grid;
|
|
821
853
|
grid-template-columns: 1fr 1fr 1fr;
|
|
822
854
|
gap: 0.25rem;
|
|
855
|
+
margin-top: 0.25rem;
|
|
823
856
|
}
|
|
824
857
|
|
|
825
858
|
.ctrls__easing-buttons button {
|
package/dist/ctrls.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../node_modules/@stanko/dual-range-input/dist/index.css","../src/scss/_ctrls.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;;AC3IF;EACE;AAAA;AAAA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;EAEA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EAGA;EAEA;EACA;EAEA;EACA;EAGA;EAGA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EAGA;EACA;EAEA;EAEA;EACA;EAEA;EAGA;EAEA;EACA;;;AAgDF;EACE;IA5CA;IAEA;IACA;IAGA;IACA;IACA;IACA;IACA;IACA;IAGA;IAGA;IACA;IACA;IACA;IAGA;IACA;IACA;IAGA;IAGA;IACA;IAEA;IAGA;IAGA;;;AASF;EAjDE;EAEA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EAGA;EACA;EAEA;EAGA;EAGA;;;AAeF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;AAAA;AAAA;EAGE;EACA;EACA;;AAGF;AAAA;EAEE;EACA;EACA;;AAGF;EACE;EACA;;AAGF;EACE;;;AAIJ;EACE;EACA;;;AAKF;AAAA;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAGF;AAAA;AAAA;EAEE;EACA;;AAKF;AAAA;EACE;EACA;EACA;;AAGF;AAAA;EACE;EACA;;;
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../node_modules/@stanko/dual-range-input/dist/index.css","../src/scss/_ctrls.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;;AC3IF;EACE;AAAA;AAAA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;EAEA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EAGA;EAEA;EACA;EAEA;EACA;EAGA;EAGA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EAGA;EACA;EAEA;EAEA;EACA;EAEA;EAGA;EAEA;EACA;;;AAgDF;EACE;IA5CA;IAEA;IACA;IAGA;IACA;IACA;IACA;IACA;IACA;IAGA;IAGA;IACA;IACA;IACA;IAGA;IACA;IACA;IAGA;IAGA;IACA;IAEA;IAGA;IAGA;;;AASF;EAjDE;EAEA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EAGA;EACA;EAEA;EAGA;EAGA;;;AAeF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;AAAA;AAAA;EAGE;EACA;EACA;;AAGF;AAAA;EAEE;EACA;EACA;;AAGF;EACE;EACA;;AAGF;EACE;;;AAIJ;EACE;EACA;;;AAKF;AAAA;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAGF;AAAA;AAAA;EAEE;EACA;;AAKF;AAAA;EACE;EACA;EACA;;AAGF;AAAA;EACE;EACA;;;AAMJ;EACE;EACA;EACA;EACA;EACA;;AAIA;EACE;;;AAMJ;EACE;EACA;EACA;EACA,YACE;EAGF;EACA;EAEA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;IACE;IACA;;;AAIJ;EACE;;;AAIA;EACE;;;AAMJ;EACE;EACA;EACA;EACA;;AAEA;EACE;;;AAIJ;EACE;;;AAGF;EACE;EACA;;AAEA;EACE;;AAGF;EACE;;;AAMJ;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAEA;EACE;;AAIJ;EACE;;;AAIJ;EACE;;;AAGF;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;;;AAMF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAIF;EAEE;;AAGF;EACE;EACA;EACA,YACE;;AAIJ;EACE;;;AAKJ;EACE;EACA;EACA;;AAEA;EAEE;EACA;EACA;;;AAKJ;EACE;EACA;EACA;EACA;EACA;;AAEA;EAEE;EACA;EACA;;;AAIJ;EACE;;AAIE;EACE;;AAGF;AAAA;AAAA;EAEE;;;AAON;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;;AAKJ;EACE;EACA;EACA;;;AAIF;EACE;;;AAIF;EACE;;;AAIF;EACE;EACA;;;AAKF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;;AAmCJ;EA5BE;EACA;EACA;EACA;EACA;EAEA;;;AA0BF;EAhCE;EACA;EACA;EACA;EACA;EAEA;;;AA8BF;EAtBE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAkBA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAKF;EAvDE;EACA;EACA;EACA;EACA;EAEA;;;AAqDF;EA7CE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAwCA;EACA;;;AAGF;EACE;EACA;;;AAKF;EAIE;;AAEA;EACE;;AAPJ;EAUE;EACA;EAEA;EACA;EACA;EAEA;EACA;EACA;EACA;EAEA;EACA;EACA;;AAEA;EACE;;;AAMJ;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;EAGF;EACA;EACA;;AAEA;EAEE;EACA;EACA;;;AAIJ;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;;;AAKF;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;;AAIJ;EACE;EACA;;AAIE;EACE;;;AAON;EACE;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;;AAIJ;EACE;EACA;;;AAGF;EACE;EACA;;AAEA;EACE;;AAKA;AAAA;AAAA;EAEE;EACA;;;AAKN;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAKF;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;;AAEA;AAAA;EAEE;EACA;EACA;;;AAIJ;EACE;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAIF;EAEE;EACA;EACA;;;AAIJ;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EAEE;;AAEA;EACE;EACA","file":"ctrls.css"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDrawer: (className?: string, children?: (HTMLElement | null)[], toggleButton?: HTMLButtonElement | null, isCollapsed?: boolean) => HTMLDivElement;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { dom } from "./dom";
|
|
2
|
+
export const getDrawer = (className = "", children = [], toggleButton, isCollapsed = false) => {
|
|
3
|
+
const inner = dom.div(`ctrls__drawer-inner ${className}-inner`, {
|
|
4
|
+
children,
|
|
5
|
+
});
|
|
6
|
+
console.log(children.length);
|
|
7
|
+
const duration = Math.min(Math.max(children.length * 75, 300), 750);
|
|
8
|
+
const outer = dom.div(`ctrls__drawer ${className}`, {
|
|
9
|
+
children: [inner],
|
|
10
|
+
style: `transition-duration: ${duration}ms`,
|
|
11
|
+
});
|
|
12
|
+
if (isCollapsed) {
|
|
13
|
+
outer.classList.add("ctrls__drawer--collapsed");
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
outer.classList.add("ctrls__drawer--expanded");
|
|
17
|
+
}
|
|
18
|
+
toggleButton?.addEventListener("click", () => {
|
|
19
|
+
outer.classList.add("ctrls__drawer--ready");
|
|
20
|
+
outer.classList.toggle("ctrls__drawer--collapsed");
|
|
21
|
+
outer.classList.toggle("ctrls__drawer--expanded");
|
|
22
|
+
toggleButton?.classList.toggle("ctrls__drawer-toggle--collapsed");
|
|
23
|
+
});
|
|
24
|
+
return outer;
|
|
25
|
+
};
|