Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32188383
D4914.1765088713.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D4914.1765088713.diff
View Options
diff --git a/web/chat/tooltip-utils.js b/web/chat/tooltip-utils.js
--- a/web/chat/tooltip-utils.js
+++ b/web/chat/tooltip-utils.js
@@ -2,6 +2,12 @@
import * as React from 'react';
+import { calculateMaxTextWidth } from '../utils/text-utils';
+import {
+ tooltipButtonStyle,
+ tooltipLabelStyle,
+ tooltipStyle,
+} from './chat-constants';
import type { PositionInfo } from './position-types';
export const tooltipPositions = Object.freeze({
@@ -39,9 +45,8 @@
const sizeOfTooltipArrow = 10; // 7px arrow + 3px extra
const appTopBarHeight = 65;
-// eslint-disable-next-line no-unused-vars
const font =
- '14px -apple-system, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", ' +
+ '14px "Inter", -apple-system, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", ' +
'"Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", ui-sans-serif';
type FindTooltipPositionArgs = {
@@ -173,5 +178,38 @@
}
return defaultPosition;
}
+type CalculateTooltipSizeArgs = {
+ +tooltipLabels: $ReadOnlyArray<string>,
+ +timestamp: string,
+};
+
+function calculateTooltipSize({
+ tooltipLabels,
+ timestamp,
+}: CalculateTooltipSizeArgs): {
+ +width: number,
+ +height: number,
+} {
+ const textWidth =
+ calculateMaxTextWidth([...tooltipLabels, timestamp], font) +
+ 2 * tooltipLabelStyle.padding;
+ const buttonsWidth =
+ tooltipLabels.length *
+ (tooltipButtonStyle.width +
+ tooltipButtonStyle.paddingLeft +
+ tooltipButtonStyle.paddingRight);
+ const width =
+ Math.max(textWidth, buttonsWidth) +
+ tooltipStyle.paddingLeft +
+ tooltipStyle.paddingRight;
+ const height =
+ (tooltipLabelStyle.height + 2 * tooltipLabelStyle.padding) * 2 +
+ tooltipStyle.rowGap * 2 +
+ tooltipButtonStyle.height;
+ return {
+ width,
+ height,
+ };
+}
-export { findTooltipPosition, sizeOfTooltipArrow };
+export { findTooltipPosition, calculateTooltipSize, sizeOfTooltipArrow };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 6:25 AM (12 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5840911
Default Alt Text
D4914.1765088713.diff (1 KB)
Attached To
Mode
D4914: [web] Introduce `calculateTooltipSize` util function
Attached
Detach File
Event Timeline
Log In to Comment