From 6c1a602bdcf5cca2a07571b7bc1227af6effe006 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Sep 2021 19:17:33 +0530 Subject: [PATCH] Made tooltip optional in IconButton --- src/app/atoms/button/IconButton.jsx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/app/atoms/button/IconButton.jsx b/src/app/atoms/button/IconButton.jsx index 34e2424e..f92752e5 100644 --- a/src/app/atoms/button/IconButton.jsx +++ b/src/app/atoms/button/IconButton.jsx @@ -16,11 +16,8 @@ import Text from '../text/Text'; const IconButton = React.forwardRef(({ variant, size, type, tooltip, tooltipPlacement, src, onClick, -}, ref) => ( - {tooltip}} - > +}, 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, }; @@ -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,