]>
git.r.bdr.sh - rbdr/lissajous/blob - lib/factories/ui.js
c220f67b208e8a23d3d2f6e6b2587e7bb81782f5
1 export function settingsContainer({id
, label
, level
=2}) {
3 const container
= document
.createElement('section');
5 container
.innerHTML
= `<h${level}>${label}</h${level}>`;
9 export function slider({
21 const sliderContainer
= document
.createElement('section');
22 sliderContainer
.classList
.add('slider');
23 sliderContainer
.classList
.add(className
);
24 const labelElement
= document
.createElement('label');
25 labelElement
.setAttribute('for', id
);
26 labelElement
.innerHTML
= label
;
27 const slider
= document
.createElement('input');
29 slider
.type
= 'range';
33 slider
.value
= get().toString();
36 document
.addEventListener('keydown', function(event
) {
38 slider
.classList
.add('shifted');
39 slider
.step
= shiftStep
;
43 document
.addEventListener('keyup', function(event
) {
44 if (event
.key
=== 'Shift') {
45 slider
.classList
.remove('shifted');
51 slider
.addEventListener('input', () => set(slider
.value
));
53 sliderContainer
.appendChild(labelElement
);
54 sliderContainer
.appendChild(slider
);
55 return sliderContainer
;