({ label, id, variant, onClick })
| 12 | * @returns {HTMLButtonElement} |
| 13 | */ |
| 14 | export function createButton({ label, id, variant, onClick }) { |
| 15 | const button = document.createElement('button'); |
| 16 | button.textContent = label; |
| 17 | button.className = 'btn'; |
| 18 | |
| 19 | if (id) { |
| 20 | button.id = id; |
| 21 | } |
| 22 | |
| 23 | if (variant) { |
| 24 | button.classList.add(variant); |
| 25 | } |
| 26 | |
| 27 | if (onClick) { |
| 28 | button.addEventListener('click', onClick); |
| 29 | } |
| 30 | |
| 31 | return button; |
| 32 | } |
no test coverage detected