Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3383345
D4911.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4911.diff
View Options
diff --git a/web/chat/tooltip-provider.js b/web/chat/tooltip-provider.js
--- a/web/chat/tooltip-provider.js
+++ b/web/chat/tooltip-provider.js
@@ -1,9 +1,11 @@
// @flow
+import classNames from 'classnames';
import invariant from 'invariant';
import * as React from 'react';
import type { TooltipPositionStyle } from './tooltip-utils';
+import css from './tooltip.css';
const onMouseLeaveSourceDisappearTimeoutMs = 200;
const onMouseLeaveTooltipDisappearTimeoutMs = 100;
@@ -112,7 +114,37 @@
tooltipCancelTimer.current = timer;
}, [clearCurrentTooltip]);
- const tooltip = React.useMemo(() => {}, []);
+ const tooltip = React.useMemo(() => {
+ if (!tooltipNode || !tooltipPosition) {
+ return null;
+ }
+ const tooltipContainerStyle = {
+ position: 'absolute',
+ top: tooltipPosition.yCoord,
+ left: tooltipPosition.xCoord,
+ };
+
+ const { verticalPosition, horizontalPosition } = tooltipPosition;
+
+ const tooltipClassName = classNames(css.tooltipAbsolute, {
+ [css.tooltipAbsoluteLeft]: horizontalPosition === 'right',
+ [css.tooltipAbsoluteRight]: horizontalPosition === 'left',
+ [css.tooltipAbsoluteTop]: verticalPosition === 'bottom',
+ [css.tooltipAbsoluteBottom]: verticalPosition === 'top',
+ });
+
+ return (
+ <div style={tooltipContainerStyle}>
+ <div
+ className={tooltipClassName}
+ onMouseEnter={onMouseEnterTooltip}
+ onMouseLeave={onMouseLeaveTooltip}
+ >
+ {tooltipNode}
+ </div>
+ </div>
+ );
+ }, [onMouseEnterTooltip, onMouseLeaveTooltip, tooltipNode, tooltipPosition]);
const value = React.useMemo(
() => ({
diff --git a/web/chat/tooltip.css b/web/chat/tooltip.css
--- a/web/chat/tooltip.css
+++ b/web/chat/tooltip.css
@@ -46,3 +46,23 @@
overflow: auto;
min-width: 72px;
}
+
+div.tooltipAbsolute {
+ position: absolute;
+}
+
+div.tooltipAbsoluteLeft {
+ left: 0;
+}
+
+div.tooltipAbsoluteRight {
+ right: 0;
+}
+
+div.tooltipAbsoluteTop {
+ top: 0;
+}
+
+div.tooltipAbsoluteBottom {
+ bottom: 0;
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 2:56 PM (7 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2597330
Default Alt Text
D4911.diff (2 KB)
Attached To
Mode
D4911: [web] Introduce tooltip container with positioning in `TooltipContext`
Attached
Detach File
Event Timeline
Log In to Comment