Made tooltip optional in IconButton
This commit is contained in:
parent
0ae994de56
commit
6c1a602bdc
1 changed files with 15 additions and 8 deletions
|
@ -16,11 +16,8 @@ import Text from '../text/Text';
|
|||
const IconButton = React.forwardRef(({
|
||||
variant, size, type,
|
||||
tooltip, tooltipPlacement, src, onClick,
|
||||
}, ref) => (
|
||||
<Tooltip
|
||||
placement={tooltipPlacement}
|
||||
content={<Text variant="b2">{tooltip}</Text>}
|
||||
>
|
||||
}, ref) => {
|
||||
const btn = (
|
||||
<button
|
||||
ref={ref}
|
||||
className={`ic-btn-${variant}`}
|
||||
|
@ -30,13 +27,23 @@ const IconButton = React.forwardRef(({
|
|||
>
|
||||
<RawIcon size={size} src={src} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
));
|
||||
);
|
||||
if (tooltip === null) return btn;
|
||||
return (
|
||||
<Tooltip
|
||||
placement={tooltipPlacement}
|
||||
content={<Text variant="b2">{tooltip}</Text>}
|
||||
>
|
||||
{btn}
|
||||
</Tooltip>
|
||||
);
|
||||
});
|
||||
|
||||
IconButton.defaultProps = {
|
||||
variant: 'surface',
|
||||
size: 'normal',
|
||||
type: 'button',
|
||||
tooltip: null,
|
||||
tooltipPlacement: 'top',
|
||||
onClick: null,
|
||||
};
|
||||
|
@ -45,7 +52,7 @@ IconButton.propTypes = {
|
|||
variant: PropTypes.oneOf(['surface']),
|
||||
size: PropTypes.oneOf(['normal', 'small', 'extra-small']),
|
||||
type: PropTypes.oneOf(['button', 'submit']),
|
||||
tooltip: PropTypes.string.isRequired,
|
||||
tooltip: PropTypes.string,
|
||||
tooltipPlacement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
||||
src: PropTypes.string.isRequired,
|
||||
onClick: PropTypes.func,
|
||||
|
|
Loading…
Reference in a new issue