1
1
import { Progressing } from '@Common/Progressing'
2
+ import { Tooltip } from '@Common/Tooltip'
2
3
import { ComponentSizeType } from '@Shared/constants'
3
4
import { ButtonProps , ButtonStyleType , ButtonVariantType } from './types'
4
5
import { BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP , BUTTON_SIZE_TO_LOADER_SIZE_MAP } from './constants'
@@ -15,23 +16,29 @@ const Button = ({
15
16
endIcon,
16
17
disabled,
17
18
isLoading,
19
+ showTippy,
20
+ tippyContent,
18
21
} : ButtonProps ) => {
22
+ const isDisabled = disabled || isLoading
19
23
const iconClass = `dc__no-shrink flex dc__fill-available-space ${ BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP [ size ] } `
20
24
21
25
return (
22
- < button
23
- { ...buttonProps }
24
- disabled = { disabled || isLoading }
25
- // eslint-disable-next-line react/button-has-type
26
- type = { buttonProps . type || 'button' }
27
- className = { `br-4 flex cursor dc__mnw-100 dc__tab-focus dc__position-rel dc__capitalize ${ getButtonDerivedClass ( { size, variant, style, isLoading } ) } ${ disabled ? 'dc__disabled' : '' } ${ buttonProps . className || '' } ` }
28
- >
29
- { startIcon && < span className = { iconClass } > { startIcon } </ span > }
30
- < span className = "dc__mxw-150 dc__align-left dc__truncate" > { text } </ span >
31
- { endIcon && < span className = { iconClass } > { endIcon } </ span > }
32
- { isLoading && < Progressing size = { BUTTON_SIZE_TO_LOADER_SIZE_MAP [ size ] } /> }
33
- </ button >
26
+ < Tooltip content = { tippyContent } alwaysShowTippyOnHover = { showTippy && ! ! tippyContent } >
27
+ < div >
28
+ < button
29
+ { ...buttonProps }
30
+ disabled = { isDisabled }
31
+ // eslint-disable-next-line react/button-has-type
32
+ type = { buttonProps . type || 'button' }
33
+ className = { `br-4 flex cursor dc__mnw-100 dc__tab-focus dc__position-rel dc__capitalize ${ getButtonDerivedClass ( { size, variant, style, isLoading } ) } ${ isDisabled ? 'dc__disabled' : '' } ${ buttonProps . className || '' } ` }
34
+ >
35
+ { startIcon && < span className = { iconClass } > { startIcon } </ span > }
36
+ < span className = "dc__mxw-150 dc__align-left dc__truncate" > { text } </ span >
37
+ { endIcon && < span className = { iconClass } > { endIcon } </ span > }
38
+ { isLoading && < Progressing size = { BUTTON_SIZE_TO_LOADER_SIZE_MAP [ size ] } /> }
39
+ </ button >
40
+ </ div >
41
+ </ Tooltip >
34
42
)
35
43
}
36
-
37
44
export default Button
0 commit comments