feat(react): add the Popover primitive#21
Open
ivanbanov wants to merge 2 commits into
Open
Conversation
Anatomy: Popover root with Trigger, Portal, Content, Title, Description, and Close compound parts, shipped as an agnostic core (@dunky.dev/popover) plus a React binding (@dunky.dev/react-popover). A non-modal floating panel toggled from its trigger that coexists with the page: Escape, an outside press, or focus leaving the panel dismisses it, and the modal option opts into a focus trap instead. 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 Popover primitive across both scopes:
@dunky.dev/popover(packages/core/popover) — the framework-free state machine and connect layer.@dunky.dev/react-popover(packages/react/popover) — the thin React compound-component binding, plus stories and a changeset.A popover is a non-modal floating panel opened from a trigger that coexists with the page: Escape, an outside press, or focus leaving the panel dismisses it, and the
modaloption opts into a focus trap with the outside hidden from assistive tech instead. Open state is exposed controlled and uncontrolled; with theopenprop set, every open/close intent is reported throughonOpenChangeand the popover only moves when the prop does, so ignoring a report is a working veto. No positioning engine in v0 — the consumer anchors the panel, anddata-stateon the trigger and panel is the styling hook.Stacked PR: this branch is based on the
feat/floatingshared-overlay-utilities extraction and targets that branch; it will retarget tomainonce the extraction PR merges.Anatomy
Behavior
aria-haspopup="dialog",aria-expanded, and — while open —aria-controls; a press while open is a toggle, never an outside interaction (no dismiss-then-reopen flicker).role="dialog",aria-modalonly whenmodal; labelled/described by the rendered Title/Description with no dangling references when a part is omitted.modaltraps focus and hides everything outside from assistive tech.Test plan
pnpm test:ci— 158 tests, 13 files, all passingpnpm typecheckpnpm lintpnpm format:checkpnpm build🤖 Generated with Claude Code