1- import React , { MouseEventHandler , ReactNode } from 'react'
1+ import React , { MouseEventHandler , ReactElement , ReactNode } from 'react'
22import { useSelector } from 'react-redux'
33import cx from 'classnames'
44import { MessageFromWebviewType } from 'dvc/src/webview/contract'
55import { FilteredCounts } from 'dvc/src/experiments/model/filterBy/collect'
6- import { TippyProps } from '@tippyjs/react'
76import styles from './styles.module.scss'
7+ import { CellHintTooltip } from './CellHintTooltip'
88import { Icon } from '../../../shared/components/Icon'
99import {
1010 Filter ,
1111 GraphScatter ,
1212 SortPrecedence
1313} from '../../../shared/components/icons'
1414import { sendMessage } from '../../../shared/vscode'
15- import Tooltip from '../../../shared/components/tooltip/Tooltip'
1615import { pluralize } from '../../../util/strings'
1716import { ExperimentsState } from '../../store'
1817
19- export type IndicatorTooltipProps = Pick < TippyProps , 'children' > & {
20- tooltipContent : ReactNode
21- }
22-
23- export const IndicatorTooltip : React . FC < IndicatorTooltipProps > = ( {
24- children,
25- tooltipContent
26- } ) => {
27- const wrapperRef = React . useRef < HTMLDivElement > ( null )
28- return (
29- < Tooltip
30- placement = "bottom-start"
31- disabled = { ! tooltipContent }
32- content = { tooltipContent }
33- ref = { wrapperRef }
34- >
35- { children }
36- </ Tooltip >
37- )
38- }
39-
4018export type CounterBadgeProps = {
4119 count ?: number
4220}
@@ -59,12 +37,13 @@ export const Indicator = ({
5937 'aria-label' : ariaLabel ,
6038 tooltipContent,
6139 onClick
62- } : IndicatorTooltipProps &
63- CounterBadgeProps & {
64- 'aria-label' ?: string
65- onClick ?: MouseEventHandler
66- } ) => (
67- < IndicatorTooltip tooltipContent = { tooltipContent } >
40+ } : CounterBadgeProps & {
41+ 'aria-label' ?: string
42+ onClick ?: MouseEventHandler
43+ tooltipContent ?: ReactNode
44+ children : ReactElement
45+ } ) => {
46+ const content = (
6847 < button
6948 className = { cx ( styles . indicatorIcon , count && styles . indicatorWithCount ) }
7049 aria-label = { ariaLabel }
@@ -73,23 +52,39 @@ export const Indicator = ({
7352 { children }
7453 < CounterBadge count = { count } />
7554 </ button >
76- </ IndicatorTooltip >
77- )
55+ )
56+
57+ return tooltipContent ? (
58+ < CellHintTooltip tooltipContent = { tooltipContent } delay = { [ 0 , 0 ] } >
59+ { content }
60+ </ CellHintTooltip >
61+ ) : (
62+ content
63+ )
64+ }
7865
7966export const IndicatorWithJustTheCounter = ( {
8067 count,
8168 'aria-label' : ariaLabel ,
8269 tooltipContent
83- } : CounterBadgeProps &
84- IndicatorTooltipProps & {
85- 'aria-label' ?: string
86- } ) => (
87- < IndicatorTooltip tooltipContent = { tooltipContent } >
70+ } : CounterBadgeProps & {
71+ 'aria-label' ?: string
72+ tooltipContent ?: ReactNode
73+ } ) => {
74+ const children = (
8875 < span aria-label = { ariaLabel } >
8976 < CounterBadge count = { count } />
9077 </ span >
91- </ IndicatorTooltip >
92- )
78+ )
79+
80+ return tooltipContent ? (
81+ < CellHintTooltip tooltipContent = { tooltipContent } >
82+ { children }
83+ </ CellHintTooltip >
84+ ) : (
85+ children
86+ )
87+ }
9388
9489const focusFiltersTree = ( ) =>
9590 sendMessage ( { type : MessageFromWebviewType . FOCUS_FILTERS_TREE } )
0 commit comments