HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/self/root/var/www/delta/wp-content/plugins/wp-smushit/_src/react/common/button.js
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>
	);
}