Refactor icon rendering; update render_icon macro to accept extra_class parameter and adjust button icons in combobox for better state management
This commit is contained in:
parent
30d3cd7c45
commit
d3a9b6dbd5
6 changed files with 13 additions and 21 deletions
|
@ -15,7 +15,15 @@ const ComboBoxWidget = (() => {
|
|||
}
|
||||
|
||||
function updateAddButtonIcon() {
|
||||
addBtn.innerHTML = currentlyEditing ? icons.edit : icons.add;
|
||||
const iconEl = addBtn.querySelector('.icon-state');
|
||||
|
||||
const iconClass = currentlyEditing ? 'bi-pencil' : 'bi-plus-lg';
|
||||
iconEl.classList.forEach(cls => {
|
||||
if (cls.startsWith('bi-') && cls !== 'icon-state') {
|
||||
iconEl.classList.remove(cls);
|
||||
}
|
||||
});
|
||||
iconEl.classList.add(iconClass);
|
||||
}
|
||||
|
||||
input.addEventListener('input', () => {
|
||||
|
@ -96,13 +104,6 @@ const ComboBoxWidget = (() => {
|
|||
}
|
||||
}
|
||||
|
||||
function sortOptions(selectElement) {
|
||||
const sorted = Array.from(selectElement.options)
|
||||
.sort((a, b) => a.text.localeCompare(b.text));
|
||||
selectElement.innerHTML = '';
|
||||
sorted.forEach(option => selectElement.appendChild(option));
|
||||
}
|
||||
|
||||
return {
|
||||
initComboBox
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue