Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3150229
D8857.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D8857.diff
View Options
diff --git a/web/utils/tooltip-utils.js b/web/utils/tooltip-utils.js
--- a/web/utils/tooltip-utils.js
+++ b/web/utils/tooltip-utils.js
@@ -8,6 +8,8 @@
tooltipButtonStyle,
tooltipLabelStyle,
tooltipStyle,
+ reactionTooltipStyle,
+ reactionSeeMoreLabel,
} from '../chat/chat-constants.js';
import type { PositionInfo } from '../chat/position-types.js';
import { calculateMaxTextWidth } from '../utils/text-utils.js';
@@ -349,8 +351,53 @@
};
}
+function calculateReactionTooltipSize(
+ usernames: $ReadOnlyArray<string>,
+): TooltipSize {
+ const showMoreTextIsShown = usernames.length > 5;
+ const {
+ maxWidth,
+ maxHeight,
+ paddingLeft,
+ paddingRight,
+ paddingTop,
+ paddingBottom,
+ rowGap,
+ } = reactionTooltipStyle;
+
+ const maxTooltipContentWidth = maxWidth;
+ const maxTooltipContentHeight = maxHeight;
+
+ const usernamesTextWidth = calculateMaxTextWidth(usernames, 14);
+ const seeMoreTextWidth = calculateMaxTextWidth([reactionSeeMoreLabel], 12);
+
+ let textWidth = usernamesTextWidth;
+ if (showMoreTextIsShown) {
+ textWidth = Math.max(usernamesTextWidth, seeMoreTextWidth);
+ }
+
+ const width =
+ Math.min(maxTooltipContentWidth, textWidth) + paddingLeft + paddingRight;
+
+ let height =
+ usernames.length * tooltipLabelStyle.height +
+ (usernames.length - 1) * rowGap;
+
+ if (showMoreTextIsShown) {
+ height = maxTooltipContentHeight;
+ }
+
+ height += paddingTop + paddingBottom;
+
+ return {
+ width,
+ height,
+ };
+}
+
export {
findTooltipPosition,
getTooltipPositionStyle,
calculateMessageTooltipSize,
+ calculateReactionTooltipSize,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 5, 10:48 PM (22 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2426675
Default Alt Text
D8857.diff (1 KB)
Attached To
Mode
D8857: [web] introduce calculateReactionTooltipSize function
Attached
Detach File
Event Timeline
Log In to Comment