feat(react): add the Tooltip primitive#8
Open
ivanbanov wants to merge 2 commits into
Open
Conversation
Adds @dunky.dev/tooltip (core machine) and @dunky.dev/react-tooltip (React binding) with the Tooltip, Tooltip.Trigger, Tooltip.Portal, and Tooltip.Content anatomy. Hover opens after a delay and closes after a grace delay; focus opens immediately; blur, Escape, and trigger press close immediately — with data-state exposed on every part for styling. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the Tooltip primitive as two packages:
@dunky.dev/tooltip— the framework-free core: a state machine implementing the WAI-ARIA APG tooltip pattern (open/close orchestration, delays, grace period) plus theconnectthat exposes parts, events, and reactions.@dunky.dev/react-tooltip— the thin React binding: a compoundTooltipcomponent wired throughuseMachine, adding no behavior of its own.A tooltip is a hover/focus description popup: it labels its trigger with contextual text, opens on intent, and never traps focus. Positioning stays with the consumer in v0.
Anatomy
Tooltip— root; holds config (openDelay,closeDelay,onOpenChange) and context.Tooltip.Trigger— the element the tooltip describes; carriesaria-describedbywhile visible.Tooltip.Portal— renders the content intodocument.body(or a custom container).Tooltip.Content— the popup itself (role="tooltip").Behavior
openDelay(700 ms default) and closes aftercloseDelay(300 ms default); re-entering the trigger or the content while closing keeps it open (grace period).role="tooltip"and is linked to the trigger viaaria-describedby; every part carriesdata-state(closed/opening/open/closing) as the styling and animation hook.Test plan
pnpm test:ci— 119 tests, 9 files, all passingpnpm typecheckpnpm lintpnpm format:checkpnpm build🤖 Generated with Claude Code