| Server IP : 127.0.0.1 / Your IP : 216.73.216.109 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10 System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64 User : SERVERWEB ( 0) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/laragon/www/prensa/wp-content/plugins/wp-smushit/_src/react/common/ |
Upload File : |
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 ? <span className={icon} aria-hidden="true"/> : "";
return (
<span className={classnames({"sui-loading-text": loading})}>
{iconTag} {text}
</span>
);
}
function loadingIcon() {
return loading
? <span className="sui-icon-loader sui-loading" aria-hidden="true"/>
: "";
}
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 (
<HtmlTag
{...props}
className={classnames(className, "sui-button-" + color, {
"sui-button-onload": loading,
"sui-button-ghost": ghost,
"sui-button-icon": !hasText,
"sui-button-dashed": dashed,
"sui-button": hasText
})}
id={id}
>
{textTag()}
{loadingIcon()}
</HtmlTag>
);
}