| 1 |
import classnames from 'classnames' |
| 2 |
import React from 'react' |
| 3 |
import { Button } from './Button' |
| 4 |
import type { ReactNode } from 'react' |
| 5 |
import type { ButtonProps } from './Button' |
| 6 |
|
| 7 |
export interface TooltipButtonProps extends ButtonProps { |
| 8 |
tooltip: ReactNode |
| 9 |
block?: boolean |
| 10 |
inline?: boolean |
| 11 |
start?: boolean |
| 12 |
end?: boolean |
| 13 |
containerClassName?: string |
| 14 |
} |
| 15 |
|
| 16 |
export const TooltipButton: React.FC<TooltipButtonProps> = ({ |
| 17 |
block, inline, start, end, |
| 18 |
tooltip, |
| 19 |
disabled, |
| 20 |
children, |
| 21 |
containerClassName, |
| 22 |
...buttonProps |
| 23 |
}) => |
| 24 |
<div className={classnames( |
| 25 |
containerClassName, |
| 26 |
!disabled && { 'tooltip-block': block, 'tooltip-inline': inline, 'tooltip-start': start, 'tooltip-end': end } |
| 27 |
)}> |
| 28 |
<Button {...buttonProps} disabled={disabled}> |
| 29 |
{children} |
| 30 |
{!disabled && <div role="tooltip" className="tooltip-content">{tooltip}</div>} |
| 31 |
</Button> |
| 32 |
</div> |
| 33 |
|