PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / common / TooltipButton.tsx

TooltipButton.tsx in Code Snippets 4.0.0-beta.2, at js/components/common/TooltipButton.tsx

33 lines 854 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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