File tree Expand file tree Collapse file tree 5 files changed +50
-8
lines changed Expand file tree Collapse file tree 5 files changed +50
-8
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export default function ClipboardButton({
75
75
>
76
76
< button
77
77
type = "button"
78
- className = { `dc__outline-none-imp p-0 flex bcn-0 dc__no-border ${ rootClassName } ` }
78
+ className = { `dc__outline-none-imp p-0 flex dc__transparent--imp dc__no-border ${ rootClassName } ` }
79
79
onMouseEnter = { handleEnableTippy }
80
80
onMouseLeave = { handleDisableTippy }
81
81
onClick = { handleCopyContent }
Original file line number Diff line number Diff line change @@ -67,13 +67,7 @@ const SortableTableHeaderCell = ({
67
67
onClick = { isSortable ? triggerSorting : noop }
68
68
disabled = { disabled }
69
69
>
70
- < Tooltip
71
- showOnTruncate = { showTippyOnTruncate }
72
- className = "default-tt"
73
- placement = "top"
74
- arrow = { false }
75
- content = { title }
76
- >
70
+ < Tooltip showOnTruncate = { showTippyOnTruncate } content = { title } >
77
71
< span className = "dc__uppercase dc__ellipsis-right" > { title } </ span >
78
72
</ Tooltip >
79
73
{ renderSortIcon ( ) }
Original file line number Diff line number Diff line change
1
+ import { useCallback , useState , cloneElement } from 'react'
2
+ import TippyJS from '@tippyjs/react'
3
+ import { TooltipProps } from './types'
4
+
5
+ const Tooltip = ( {
6
+ showOnTruncate = false ,
7
+ alwaysShowTippyOnHover = false ,
8
+ children : child ,
9
+ ...rest
10
+ } : TooltipProps ) => {
11
+ const [ isTextTruncated , setIsTextTruncated ] = useState ( false )
12
+
13
+ const refCallback = useCallback ( ( node : HTMLDivElement ) => {
14
+ if ( node ) {
15
+ setIsTextTruncated ( node . scrollWidth > node . clientWidth || node . scrollHeight > node . clientHeight )
16
+ }
17
+ } , [ ] )
18
+
19
+ return ( ! isTextTruncated || ! showOnTruncate ) && ! alwaysShowTippyOnHover ? (
20
+ cloneElement ( child , { ...child . props , ref : refCallback } )
21
+ ) : (
22
+ < TippyJS
23
+ arrow = { false }
24
+ placement = "top"
25
+ { ...rest }
26
+ className = { `default-tt dc__word-break-all dc__mxw-200 ${ rest . className } ` }
27
+ >
28
+ { cloneElement ( child , { ...child . props , ref : refCallback } ) }
29
+ </ TippyJS >
30
+ )
31
+ }
32
+
33
+ export default Tooltip
Original file line number Diff line number Diff line change
1
+ export { default as Tooltip } from './Tooltip'
Original file line number Diff line number Diff line change
1
+ import { TippyProps } from '@tippyjs/react'
2
+
3
+ export interface TooltipProps extends TippyProps {
4
+ /**
5
+ * If true, show tippy on truncate
6
+ * @default false
7
+ */
8
+ showOnTruncate ?: boolean
9
+ /**
10
+ * If true, wrap with tippy irrespective of other options
11
+ * @default false
12
+ */
13
+ alwaysShowTippyOnHover ?: boolean
14
+ }
You can’t perform that action at this time.
0 commit comments