Tooltip.js — react Source File
Architecture documentation for Tooltip.js, a javascript file in the react codebase. 3 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 67a53ff5_5364_e0e2_039c_5bb44dfc1bd6["Tooltip.js"] 2468384f_08f9_03e5_6d41_24e3f2f7eb2a["Tooltip.css"] 67a53ff5_5364_e0e2_039c_5bb44dfc1bd6 --> 2468384f_08f9_03e5_6d41_24e3f2f7eb2a ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] 67a53ff5_5364_e0e2_039c_5bb44dfc1bd6 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 ebb48597_9981_bb7d_08db_b9fe29a0f62e["SyntheticEvent"] 67a53ff5_5364_e0e2_039c_5bb44dfc1bd6 --> ebb48597_9981_bb7d_08db_b9fe29a0f62e 54e7a598_e83a_4b14_3104_1fa62a034c31["CommitFlamegraph.js"] 54e7a598_e83a_4b14_3104_1fa62a034c31 --> 67a53ff5_5364_e0e2_039c_5bb44dfc1bd6 0ad6c6d5_5d6d_2d8a_d957_e1433af66ea0["CommitRanked.js"] 0ad6c6d5_5d6d_2d8a_d957_e1433af66ea0 --> 67a53ff5_5364_e0e2_039c_5bb44dfc1bd6 76384bd4_08c7_de17_1f91_2937028def49["SnapshotCommitList.js"] 76384bd4_08c7_de17_1f91_2937028def49 --> 67a53ff5_5364_e0e2_039c_5bb44dfc1bd6 style 67a53ff5_5364_e0e2_039c_5bb44dfc1bd6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @flow */
import * as React from 'react';
import {useRef} from 'react';
import styles from './Tooltip.css';
import typeof {SyntheticMouseEvent} from 'react-dom-bindings/src/events/SyntheticEvent';
const initialTooltipState = {height: 0, mouseX: 0, mouseY: 0, width: 0};
export default function Tooltip({
children,
className,
label,
style,
}: any): React.Node {
const containerRef = useRef(null);
const tooltipRef = useRef(null);
// update the position of the tooltip based on current mouse position
const updateTooltipPosition = (event: SyntheticMouseEvent) => {
const element = tooltipRef.current;
if (element != null) {
// first find the mouse position
const mousePosition = getMousePosition(containerRef.current, event);
// use the mouse position to find the position of tooltip
const {left, top} = getTooltipPosition(element, mousePosition);
// update tooltip position
element.style.left = left;
element.style.top = top;
}
};
const onMouseMove = (event: SyntheticMouseEvent) => {
updateTooltipPosition(event);
};
const tooltipClassName = label === null ? styles.hidden : '';
return (
<div
className={styles.Container}
onMouseMove={onMouseMove}
ref={containerRef}>
<div
className={`${styles.Tooltip} ${tooltipClassName} ${className || ''}`}
ref={tooltipRef}
style={style}>
{label}
</div>
{children}
</div>
);
}
const TOOLTIP_OFFSET = 5;
// Method used to find the position of the tooltip based on current mouse position
function getTooltipPosition(
element: empty,
// ... (67 more lines)
Domain
Subdomains
Dependencies
- SyntheticEvent
- Tooltip.css
- react
Imported By
Source
Frequently Asked Questions
What does Tooltip.js do?
Tooltip.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in Tooltip.js?
Tooltip.js defines 3 function(s): Tooltip, getMousePosition, getTooltipPosition.
What does Tooltip.js depend on?
Tooltip.js imports 3 module(s): SyntheticEvent, Tooltip.css, react.
What files import Tooltip.js?
Tooltip.js is imported by 3 file(s): CommitFlamegraph.js, CommitRanked.js, SnapshotCommitList.js.
Where is Tooltip.js in the architecture?
Tooltip.js is located at packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Profiler).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free