import { Link, LocationProvider } from '@reach/router'; import router from '@elementor/router'; import Icon from 'elementor-app/ui/atoms/icon'; export default class Button extends React.Component { static propTypes = { text: PropTypes.string.isRequired, hideText: PropTypes.bool, icon: PropTypes.string, tooltip: PropTypes.string, id: PropTypes.string, className: PropTypes.string, url: PropTypes.string, onClick: PropTypes.func, variant: PropTypes.oneOf( [ 'contained', 'underlined', 'outlined', '' ] ), color: PropTypes.oneOf( [ 'primary', 'secondary', 'cta', 'link', 'disabled' ] ), size: PropTypes.oneOf( [ 'sm', 'md', 'lg' ] ), target: PropTypes.string, rel: PropTypes.string, elRef: PropTypes.object, }; static defaultProps = { id: '', className: '', variant: '', target: '_parent', }; getCssId() { return this.props.id; } getClassName() { const baseClassName = 'eps-button', classes = [ baseClassName, this.props.className ]; return classes .concat( this.getStylePropsClasses( baseClassName ) ) .filter( ( classItem ) => '' !== classItem ) .join( ' ' ); } getStylePropsClasses( baseClassName ) { const styleProps = [ 'color', 'size', 'variant' ], stylePropClasses = []; styleProps.forEach( ( styleProp ) => { const stylePropValue = this.props[ styleProp ]; if ( stylePropValue ) { stylePropClasses.push( baseClassName + '--' + stylePropValue ); } } ); return stylePropClasses; } getIcon() { if ( this.props.icon ) { const tooltip = this.props.tooltip || this.props.text; const icon =