import React from 'react'; import PropTypes from 'prop-types'; import './IconButton.scss'; import RawIcon from '../system-icons/RawIcon'; import Tooltip from '../tooltip/Tooltip'; import { blurOnBubbling } from './script'; import Text from '../text/Text'; const IconButton = React.forwardRef(({ variant, size, type, tooltip, tooltipPlacement, src, onClick, tabIndex, disabled, }, ref) => { const btn = ( ); if (tooltip === null) return btn; return ( {tooltip}} > {btn} ); }); IconButton.defaultProps = { variant: 'surface', size: 'normal', type: 'button', tooltip: null, tooltipPlacement: 'top', onClick: null, tabIndex: 0, disabled: false, }; IconButton.propTypes = { variant: PropTypes.oneOf(['surface', 'primary', 'positive', 'caution', 'danger']), size: PropTypes.oneOf(['normal', 'small', 'extra-small']), type: PropTypes.oneOf(['button', 'submit', 'reset']), tooltip: PropTypes.string, tooltipPlacement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']), src: PropTypes.string.isRequired, onClick: PropTypes.func, tabIndex: PropTypes.number, disabled: PropTypes.bool, }; export default IconButton;