MCPcopy Create free account
hub / github.com/dailydotdev/apps / BaseTooltip

Function BaseTooltip

packages/shared/src/components/tooltips/BaseTooltip.tsx:58–114  ·  view source on GitHub ↗
(
  {
    render,
    showArrow = true,
    placement = 'top',
    delay = DEFAULT_DELAY_MS,
    duration = DEFAULT_DURATION,
    container = {},
    disabled,
    children,
    content,
    ...props
  }: BaseTooltipProps,
  ref?: Ref<Element>,
)

Source from the content-addressed store, hash-verified

56}
57
58export function BaseTooltip(
59 {
60 render,
61 showArrow = true,
62 placement = 'top',
63 delay = DEFAULT_DELAY_MS,
64 duration = DEFAULT_DURATION,
65 container = {},
66 disabled,
67 children,
68 content,
69 ...props
70 }: BaseTooltipProps,
71 ref?: Ref<Element>,
72): ReactElement {
73 const [mounted, setMounted] = useState(false);
74
75 const lazyPlugin = {
76 fn: () => ({
77 onMount: () => !disabled && setMounted(true),
78 onHidden: () => setMounted(false),
79 }),
80 };
81
82 return (
83 <Tippy
84 ref={ref}
85 {...props}
86 maxWidth=""
87 plugins={[
88 lazyPlugin,
89 ...(Array.isArray(props.plugins) ? props.plugins : []),
90 ]}
91 placement={placement}
92 delay={delay}
93 duration={duration}
94 className={styles.tippyTooltip}
95 allowHTML
96 arrow={false} // disable tippy arrow since we alway inject custom one through BaseTooltipContainer
97 content={
98 !content || disabled ? (
99 <></>
100 ) : (
101 <BaseTooltipContainer
102 {...container}
103 showArrow={showArrow}
104 placement={placement}
105 >
106 {mounted && content}
107 </BaseTooltipContainer>
108 )
109 }
110 >
111 {children}
112 </Tippy>
113 );
114}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected