website: dca sim: improve reactivity

This commit is contained in:
nym21
2024-12-04 11:15:18 +01:00
parent 8af1ddd10d
commit d4323fb5e0
3 changed files with 346 additions and 266 deletions

View File

@@ -622,6 +622,39 @@ const utils = {
return div;
},
/**
* @param {Object} args
* @param {string} args.title
* @param {string} args.description
* @param {HTMLElement} args.input
*/
createFieldElement({ title, description, input }) {
const div = window.document.createElement("div");
const label = window.document.createElement("label");
div.append(label);
const titleElement = window.document.createElement("span");
titleElement.innerHTML = title;
label.append(titleElement);
const descriptionElement = window.document.createElement("small");
descriptionElement.innerHTML = description;
label.append(descriptionElement);
div.append(input);
const forId = input.id || input.firstElementChild?.id;
if (!forId) {
console.log(input);
throw `Input should've an ID`;
}
label.htmlFor = forId;
return div;
},
/**
* @param {'left' | 'bottom' | 'top' | 'right'} position
*/