mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
45 lines
997 B
JavaScript
45 lines
997 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classNames from 'classnames';
|
|
|
|
const defaultRender = (inner) => inner;
|
|
|
|
export default function IconButton({
|
|
onClick,
|
|
Icon,
|
|
disabled,
|
|
label,
|
|
tooltipRender,
|
|
className,
|
|
...props
|
|
}) {
|
|
const renderWrapper = tooltipRender ?? defaultRender;
|
|
return (
|
|
<button
|
|
className={classNames('icon-button', className, {
|
|
'icon-button--disabled': disabled,
|
|
})}
|
|
data-testid={props['data-testid'] ?? undefined}
|
|
onClick={onClick}
|
|
disabled={disabled}
|
|
>
|
|
{renderWrapper(
|
|
<>
|
|
<div className="icon-button__circle">{Icon}</div>
|
|
<span>{label}</span>
|
|
</>,
|
|
)}
|
|
</button>
|
|
);
|
|
}
|
|
|
|
IconButton.propTypes = {
|
|
onClick: PropTypes.func.isRequired,
|
|
Icon: PropTypes.func.isRequired,
|
|
disabled: PropTypes.bool,
|
|
label: PropTypes.string.isRequired,
|
|
tooltipRender: PropTypes.func,
|
|
className: PropTypes.string,
|
|
'data-testid': PropTypes.string,
|
|
};
|