Skip to content

Conversation

@fhqvst
Copy link
Contributor

@fhqvst fhqvst commented Dec 15, 2025

Summary

In this PR we add a simple tooltip to the price chart.

Rationale

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

@linear
Copy link

linear bot commented Dec 15, 2025

@fhqvst fhqvst self-assigned this Dec 15, 2025
@vercel
Copy link

vercel bot commented Dec 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
component-library Ready Ready Preview, Comment Dec 16, 2025 2:31pm
insights Error Error Dec 16, 2025 2:31pm
5 Skipped Deployments
Project Deployment Review Updated (UTC)
api-reference Skipped Skipped Dec 16, 2025 2:31pm
developer-hub Skipped Skipped Dec 16, 2025 2:31pm
entropy-explorer Skipped Skipped Dec 16, 2025 2:31pm
proposals Skipped Skipped Dec 16, 2025 2:31pm
staking Skipped Skipped Dec 16, 2025 2:31pm

@fhqvst fhqvst force-pushed the fhqvst/ui-379-chart-add-tooltip-hover-card branch from 6c9bbf4 to f01ba24 Compare December 16, 2025 14:28
@vercel vercel bot temporarily deployed to Preview – developer-hub December 16, 2025 14:28 Inactive
@vercel vercel bot temporarily deployed to Preview – staking December 16, 2025 14:28 Inactive
@vercel vercel bot temporarily deployed to Preview – api-reference December 16, 2025 14:28 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer December 16, 2025 14:28 Inactive
@vercel vercel bot temporarily deployed to Preview – proposals December 16, 2025 14:28 Inactive
const priceValue = priceData.value;
const date = new Date(Number(param.time) * 1000);
const formattedDate = dateFormatter.format(date);
const formattedPrice = priceFormatter.format(priceValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I see that it might not be possible to use the React Aria component, since we're tying into the Trading View widget's events.

we may be able to still leverage the useTooltip() hook, though, to ensure proper a11y is maintained for it, though 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The price chart itself is a canvas, so I'm not sure what we can actually do here when it comes to a11y. The tooltip kinda assumes the user is able to interact with a price line within the canvas by using their mouse. The tooltip contains no interactive elements.

If anything we should update the aria-label of the <canvas> itself, but yeah...

Copy link
Collaborator

@cprussin cprussin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great but let's stick to react & react-aria Tooltip if possible.

Even if react-aria isn't possible, using react to render the tooltip and just having the callback set state that controls the visibility of it should be completely doable without the awkward manual html string interpolation and dropping to manual DOM building.

Comment on lines +457 to +474
tooltip.innerHTML = `
<table class="${styles.tooltipTable ?? ""}">
<tbody>
<tr>
<td colspan="2">${formattedDate}</td>
</tr>
<tr>
<tr>
<td>Price</td>
<td>${formattedPrice}</td>
</tr>
<tr>
<td>Confidence</td>
<td>${confidenceText}</td>
</tr>
</tbody>
</table>
`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure you can do this with react & react-aria by using a react-aria Tooltip component, and just use this callback to set state that controls the position & visibility of the tooltip. That would clean up the code considerably and remove a lot of the awkward manual html building, plus you'd get all the accessibility niceness of react-aria.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants