import React from "react";
import classnames from "classnames";
export default function Button(
{
id = "",
text = "",
color = "",
dashed = false,
icon = '',
loading = false,
ghost = false,
disabled = false,
href = "",
target = "",
className = "",
onClick = () => false,
}
) {
function handleClick(e) {
e.preventDefault();
onClick();
}
function textTag() {
const iconTag = icon ? : "";
return (
{iconTag} {text}
);
}
function loadingIcon() {
return loading
?
: "";
}
let HtmlTag, props;
if (href) {
HtmlTag = 'a';
props = {href: href, target: target};
} else {
HtmlTag = 'button';
props = {
disabled: disabled,
onClick: e => handleClick(e)
};
}
const hasText = text && text.trim();
return (
{textTag()}
{loadingIcon()}
);
}