Skip to content

Commit

Permalink
Fix root cause of #47 and improve tooltip styling
Browse files Browse the repository at this point in the history
Tooltips would go offscreen because of the way `top` is defined. This
commit fixes that root cause by changing CanvasPage to position fixed so
that tooltips will be positioned relative to the DOM rather than the
CanvasPage div.

Undoes some of the changes made in #78 as this commit fixes the root
cause of the bug.
  • Loading branch information
taneliang committed Aug 6, 2020
1 parent 25d1626 commit f8d59d8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/CanvasPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
bottom: 0.5rem;
left: 0.5rem;
right: 0.5rem;
overflow: hidden;
}
20 changes: 18 additions & 2 deletions src/EventTooltip.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Tooltip {
position: absolute;
position: fixed;
display: inline-block;
border-radius: 0.125rem;
max-width: 300px;
Expand Down Expand Up @@ -31,12 +31,20 @@
}

.DetailsGridURL {
word-break: break-all;
max-height: 50vh;
overflow: hidden;
}

.FlamechartStackFrameName {
word-break: break-word;
margin-left: 0.4rem;
}

.ComponentName {
font-weight: bold;
word-wrap: break-word;
word-break: break-word;
margin-right: 0.4rem;
}

.ComponentStack {
Expand All @@ -61,3 +69,11 @@
white-space: pre;
--gradient-height: 5em;
}

.ReactMeasureLabel {
margin-left: 0.4rem;
}

.UserTimingLabel {
word-break: break-word;
}
10 changes: 6 additions & 4 deletions src/EventTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ const TooltipFlamechartNode = ({
} = stackFrame;
return (
<div className={styles.Tooltip} ref={tooltipRef}>
{formatDuration(duration)} {trimComponentName(name)}
{formatDuration(duration)}
<span className={styles.FlamechartStackFrameName}>{name}</span>
<div className={styles.DetailsGrid}>
<div className={styles.DetailsGridLabel}>Timestamp:</div>
<div>{formatTimestamp(timestamp)}</div>
Expand Down Expand Up @@ -202,7 +203,7 @@ const TooltipReactEvent = ({
<span className={styles.ComponentName} style={{color}}>
{trimComponentName(componentName)}
</span>
)}{' '}
)}
{label}
<div className={styles.Divider} />
<div className={styles.DetailsGrid}>
Expand Down Expand Up @@ -241,7 +242,8 @@ const TooltipReactMeasure = ({

return (
<div className={styles.Tooltip} ref={tooltipRef}>
{formatDuration(duration)} {label}
{formatDuration(duration)}
<span className={styles.ReactMeasureLabel}>{label}</span>
<div className={styles.Divider} />
<div className={styles.DetailsGrid}>
<div className={styles.DetailsGridLabel}>Timestamp:</div>
Expand All @@ -267,7 +269,7 @@ const TooltipUserTimingMark = ({
const {name, timestamp} = mark;
return (
<div className={styles.Tooltip} ref={tooltipRef}>
{name}
<span className={styles.UserTimingLabel}>{name}</span>
<div className={styles.Divider} />
<div className={styles.DetailsGrid}>
<div className={styles.DetailsGridLabel}>Timestamp:</div>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/useSmartTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function useSmartTooltip({
element.style.left = `${mouseX + TOOLTIP_OFFSET}px`;
}
}
});
}, [mouseX, mouseY, ref]);

return ref;
}

0 comments on commit f8d59d8

Please sign in to comment.