Skip to content

Tooltip component#304

Open
jav1anpry5ce wants to merge 5 commits intomainfrom
tooltip-component
Open

Tooltip component#304
jav1anpry5ce wants to merge 5 commits intomainfrom
tooltip-component

Conversation

@jav1anpry5ce
Copy link
Collaborator

This PR adds a reusable component that shows a tooltip with a custom string passed as a prop.

Example usage:

<QuestionTooltip text="This is a demonstration of the new Tooltip component in action!" />
image

Copy link
Collaborator

@Justin-MacIntosh Justin-MacIntosh left a comment

Choose a reason for hiding this comment

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

This is awesome to see. This component is going to save us a lot of headaches down the line, thank you!

<QuestionMarkIcon class="size-5 text-gray-500 hover:text-gray-700 transition-colors" />
)}

{isVisible() && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

For stuff like this, we've been using the builtin Show from SolidJS :
https://docs.solidjs.com/reference/components/show

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had no idea this method existed. Solid JS seems better than React JS


const handleMouseEnter = () => {
if (containerRef) {
const rect = containerRef.getBoundingClientRect();
Copy link
Collaborator

Choose a reason for hiding this comment

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

For readability, I have a few small nitpicks here:

  • Creating a typescript type called something like TooltipAlignment set to 'center' | 'left' | 'right'.
  • Having the handleMouseEnter(...) function call another function for determining alignment that returns a TooltipAlignment, and then setting setPosition(...); based on the return value.

This would make it easier at-a-glance to know what handleMouseEnter(...) does. This is purely stylistic so feel free to ignore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense. It would make the code more readable and maintainable.

class={`absolute w-3 h-3 bg-white border-t border-l border-gray-200 rotate-45 -top-[7px] ${
position().align === 'center' ? 'left-1/2 -translate-x-1/2' :
position().align === 'left' ? 'left-3' :
'right-3'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Right now, the arrow isn't pointing at the center of the tooltip. We should aim for that, or remove the arrow entirely if the math of hitting the center is too complicated and error-prone.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what you mean here. This doesn't need to exist, and is for decoration.

Without
image

With
image

Copy link
Collaborator

@Justin-MacIntosh Justin-MacIntosh Feb 28, 2026

Choose a reason for hiding this comment

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

Sorry for not being clear. I meant that typically the arrow on a tooltip points directly to the center of the thing it's pointing at, in this case that would be the question mark. But as is, the arrow is pointing a little to the left when the tooltip is right-aligned. I was suggesting we should try to fix that and point to the center, but that if it's too much trouble we could just remove the arrow entirely.

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.

2 participants