26 lines
713 B
JavaScript
26 lines
713 B
JavaScript
function icon(name) {
|
|
const inconElement = document.createElement("i");
|
|
inconElement.classList.add("bi", `bi-${name}`);
|
|
return inconElement;
|
|
};
|
|
|
|
function button(text, iconName, color = "primary") {
|
|
const buttonElement = document.createElement("button");
|
|
buttonElement.classList.add("btn", `btn-${color}`);
|
|
buttonElement.setAttribute("type", "button");
|
|
if (text) {
|
|
buttonElement.innerText = text;
|
|
}
|
|
if (icon) {
|
|
buttonElement.appendChild(icon(iconName));
|
|
}
|
|
return buttonElement;
|
|
};
|
|
|
|
export function buttonText(text, color) {
|
|
return button(text, null, color);
|
|
}
|
|
|
|
export function buttonIcon(iconName, color) {
|
|
return button(null, iconName, color);
|
|
} |