/**
* External dependencies
*/
import React from 'react';
import classNames from 'classnames';
/**
* Button functional component.
*
* @param {Object} props Component props.
* @param {string|JSX.Element} props.text Button text.
* @param {string} props.url URL link.
* @param {Array|Object} props.classes Button class.
* @param {string} props.id Button ID.
* @param {string|JSX.Element} props.icon SUI icon class.
* @param {string} props.target Target __blank?
* @param {boolean} props.disabled Disabled or not.
* @param {*} props.onClick onClick callback.
* @param {string} props.type Link or button.
* @return {JSX.Element} Button component.
* @class
*/
export default function Button( {
text,
url = '#',
classes,
id,
icon,
target,
disabled = false,
onClick,
type = 'link',
...props
} ) {
if ( icon ) {
icon = ;
}
if ( 'button' === type ) {
return (
);
}
let rel;
if ( 'blank' === target || '_blank' === target ) {
target = '_blank';
rel = 'noopener noreferrer';
}
return (
{ ! window.lodash.includes( classes, 'sui-button-icon-right' ) && icon }
{ text }
{ window.lodash.includes( classes, 'sui-button-icon-right' ) && icon }
);
}