@stanko/ctrls 0.4.4 → 0.4.5
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 +3 -2
- package/dist/ctrls/index.d.ts +0 -1
- package/dist/ctrls/index.js +13 -21
- package/dist/ctrls.css +43 -24
- package/dist/ctrls.css.map +1 -1
- package/dist/utils/get-drawer.d.ts +1 -0
- package/dist/utils/get-drawer.js +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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,25 +346,43 @@
|
|
|
346
346
|
width: 1rem;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
.
|
|
350
|
-
|
|
349
|
+
.ctrls__controls-inner {
|
|
350
|
+
overflow: auto;
|
|
351
|
+
scrollbar-width: thin;
|
|
352
|
+
scrollbar-color: var(--ctrls-scrollbar-thumb-bg) transparent;
|
|
353
|
+
}
|
|
354
|
+
.ctrls__controls-inner > *:last-child:not(:first-child) {
|
|
355
|
+
margin-bottom: 0.25rem;
|
|
351
356
|
}
|
|
352
357
|
|
|
353
|
-
.
|
|
354
|
-
|
|
355
|
-
|
|
358
|
+
.ctrls__drawer {
|
|
359
|
+
display: none;
|
|
360
|
+
align-items: flex-start;
|
|
361
|
+
grid-template-rows: 0fr;
|
|
362
|
+
transition: grid-template-rows 500ms, opacity 500ms, display 500ms;
|
|
363
|
+
transition-behavior: allow-discrete;
|
|
364
|
+
overflow: hidden;
|
|
365
|
+
opacity: 0;
|
|
356
366
|
}
|
|
357
367
|
|
|
358
|
-
.
|
|
359
|
-
overflow: auto;
|
|
368
|
+
.ctrls__drawer--expanded {
|
|
360
369
|
display: grid;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
scrollbar-color: var(--ctrls-scrollbar-thumb-bg) transparent;
|
|
370
|
+
grid-template-rows: 1fr;
|
|
371
|
+
opacity: 1;
|
|
364
372
|
}
|
|
365
373
|
|
|
366
|
-
|
|
367
|
-
|
|
374
|
+
@starting-style {
|
|
375
|
+
.ctrls__drawer--ready.ctrls__drawer--expanded {
|
|
376
|
+
grid-template-rows: 0fr;
|
|
377
|
+
opacity: 0;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
.ctrls__drawer-inner {
|
|
381
|
+
overflow: hidden;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.ctrls__drawer-toggle--collapsed svg {
|
|
385
|
+
transform: rotate(180deg);
|
|
368
386
|
}
|
|
369
387
|
|
|
370
388
|
.ctrls__group {
|
|
@@ -373,19 +391,14 @@
|
|
|
373
391
|
border-radius: var(--ctrls-radius);
|
|
374
392
|
overflow: hidden;
|
|
375
393
|
}
|
|
394
|
+
.ctrls__group:only-child {
|
|
395
|
+
margin-block: 0.5rem;
|
|
396
|
+
}
|
|
376
397
|
|
|
377
398
|
.ctrls__group .ctrls__control {
|
|
378
399
|
grid-template-columns: calc(var(--ctrls-label-width) - 0.5rem) minmax(0, 1fr);
|
|
379
400
|
}
|
|
380
401
|
|
|
381
|
-
.ctrls__group--hidden {
|
|
382
|
-
padding-block-end: 0;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
.ctrls__group--hidden .ctrls__control {
|
|
386
|
-
display: none;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
402
|
.ctrls__control {
|
|
390
403
|
padding: 0.25rem 0.5rem;
|
|
391
404
|
display: grid;
|
|
@@ -398,6 +411,13 @@
|
|
|
398
411
|
.ctrls__control:hover .ctrls__control-label {
|
|
399
412
|
color: var(--ctrls-theme);
|
|
400
413
|
}
|
|
414
|
+
.ctrls__control:only-child {
|
|
415
|
+
padding-block: 0.5rem;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.ctrls__control-no-label {
|
|
419
|
+
padding: 0.25rem 0.5rem 0.25rem calc(var(--ctrls-label-width) + 0.5rem);
|
|
420
|
+
}
|
|
401
421
|
|
|
402
422
|
.ctrls__control-label {
|
|
403
423
|
color: var(--ctrls-text-muted);
|
|
@@ -446,8 +466,7 @@
|
|
|
446
466
|
}
|
|
447
467
|
|
|
448
468
|
.ctrls__btn--lg {
|
|
449
|
-
|
|
450
|
-
margin-inline-end: 0.5rem;
|
|
469
|
+
width: 100%;
|
|
451
470
|
padding: 0.5rem 1rem;
|
|
452
471
|
background: var(--ctrls-btn-bg);
|
|
453
472
|
border: 1px solid var(--ctrls-input-border);
|
|
@@ -460,7 +479,7 @@
|
|
|
460
479
|
}
|
|
461
480
|
|
|
462
481
|
.ctrls__randomize {
|
|
463
|
-
|
|
482
|
+
grid-column: 2;
|
|
464
483
|
}
|
|
465
484
|
.ctrls__randomize:focus-visible svg, .ctrls__randomize:hover svg {
|
|
466
485
|
transform: rotate(0.5turn);
|
|
@@ -776,7 +795,6 @@ label:hover .ctrls__boolean-input:not(:checked) + .ctrls__boolean-checkmark {
|
|
|
776
795
|
border: 1px solid var(--ctrls-input-border);
|
|
777
796
|
background: var(--ctrls-input-wrapper-bg);
|
|
778
797
|
border-radius: min(var(--ctrls-radius), 12px);
|
|
779
|
-
margin-bottom: 0.25rem;
|
|
780
798
|
}
|
|
781
799
|
|
|
782
800
|
.ctrls__easing {
|
|
@@ -820,6 +838,7 @@ label:hover .ctrls__boolean-input:not(:checked) + .ctrls__boolean-checkmark {
|
|
|
820
838
|
display: grid;
|
|
821
839
|
grid-template-columns: 1fr 1fr 1fr;
|
|
822
840
|
gap: 0.25rem;
|
|
841
|
+
margin-top: 0.25rem;
|
|
823
842
|
}
|
|
824
843
|
|
|
825
844
|
.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;;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;;;AAKF;EACE;EACA;EACA;EACA;;AAEA;EACE;;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,22 @@
|
|
|
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
|
+
const outer = dom.div(`ctrls__drawer ${className}`, {
|
|
7
|
+
children: [inner],
|
|
8
|
+
});
|
|
9
|
+
if (isCollapsed) {
|
|
10
|
+
outer.classList.add("ctrls__drawer--collapsed");
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
outer.classList.add("ctrls__drawer--expanded");
|
|
14
|
+
}
|
|
15
|
+
toggleButton?.addEventListener("click", () => {
|
|
16
|
+
outer.classList.add("ctrls__drawer--ready");
|
|
17
|
+
outer.classList.toggle("ctrls__drawer--collapsed");
|
|
18
|
+
outer.classList.toggle("ctrls__drawer--expanded");
|
|
19
|
+
toggleButton?.classList.toggle("ctrls__drawer-toggle--collapsed");
|
|
20
|
+
});
|
|
21
|
+
return outer;
|
|
22
|
+
};
|