-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Moved hover tooltip rendering logic into component #491
Conversation
(cherry picked from commit c8e5170)
…overTooltip, renamed state values for clarity
|
Coverage Report
File CoverageNo changed files found. |
const [lastValidHoveredId, setLastValidHoveredId] = useState<number>(-1); | ||
const [showObjectHoverInfo, setShowObjectHoverInfo] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1
is okay here as a placeholder value, because showObjectHoverInfo
is only set to true when lastValidHoveredId
can be set to a valid ID number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you called this out, it's definitely odd to call it a "valid" hovered id when -1 is allowed!
} | ||
}; | ||
|
||
// TODO: Move to a separate component? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
type CanvasHoverTooltipProps = { | ||
dataset: Dataset | null; | ||
featureKey: string; | ||
lastValidHoveredId: number; | ||
showObjectHoverInfo: boolean; | ||
motionDeltas: Float32Array | null; | ||
config: ViewerConfig; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could really use redux or a state management framework here...
const TooltipCard = styled.div` | ||
font-family: var(--default-font); | ||
|
||
border-radius: var(--radius-control-small); | ||
border: 1px solid var(--color-dividers); | ||
background-color: var(--color-background); | ||
padding: 6px 8px; | ||
overflow-wrap: break-word; | ||
|
||
transition: opacity 300ms; | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from HoverTooltip.tsx
const [lastValidHoveredId, setLastValidHoveredId] = useState<number>(-1); | ||
const [showObjectHoverInfo, setShowObjectHoverInfo] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you called this out, it's definitely odd to call it a "valid" hovered id when -1 is allowed!
Problem
Refactors the rendering logic for hover tooltips into a separate component. As part of this change, I also changed some variable names for clarity and moved component styling.
This will eventually let me add a tag tooltip that follows the mouse as part of #484!
Estimated size: small, 10-20 minutes (faster if you compare deleted changes!!!)
Solution
Viewer.tsx
and into a new component,CanvasHoverTooltip.tsx
.HoverTooltip.tsx
and intoCanvasHoverTooltip.tsx
.Viewer.tsx
for clarity.Steps to Verify: