feat(Menu): cursor-anchored context menu (useContextMenu) + Badge/build tidy - #25
Merged
Conversation
Add useContextMenu — a right-click, cursor-anchored menu built on a controlled non-modal MenuTrigger. Non-modal so a right-click on another element reaches its own handler (a modal underlay swallows it and leaks the native menu); the hook owns dismissal (outside press, right-click elsewhere, Escape) since non-modal drops React-Aria's built-in dismiss. Also forward ref on IconButton/IconButtonLink/IconButtonToggle (React 19 ref-as-prop) and extract shared popover chrome to menuStyles. Context usage is demonstrated in the Menu story (no separate component/story).
Bake tabular-nums and tracking-wider into Badge so count pills align and read consistently without per-use classes. Rewrite the story to the Button pattern (AllVariants grid first, Playground, focused examples), dropping the per-variant/per-size/app-specific slop.
tsup's onSuccess regenerates the stylesheet in the same pass as the JS, so dist/index.css can't go missing mid-rebuild for linked consumers (dev). Drops the need for a separate, race-prone CSS watcher.
|
🎉 This PR is included in version 7.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
useContextMenu— a right-click, cursor-anchored menu built on a controlled, non-modalMenuTrigger. Non-modal so a right-click on another element reaches its own handler (a modal underlay swallows it and leaks the native menu); the hook owns dismissal (outside press, right-click elsewhere, Escape) since non-modal drops React-Aria's built-in dismiss. Cursor anchoring via a hiddenPressableanchor moved to the pointer. Context usage demonstrated in the Menu story (no separate component/story). Shared popover chrome extracted tomenuStyles.IconButton/IconButtonLink/IconButtonTogglenow forwardref(React 19 ref-as-prop).Badge—tabular-nums+tracking-wideras defaults (count pills align + read consistently); story rewritten to the Button pattern.tsuponSuccessrebuildsdist/index.cssin the same pass as JS, so the stylesheet can't go missing mid-rebuild for linked (dev) consumers.Why
Replaces a
querySelector().click()hack in cytario-web's right-click menus (NodeLink, annotation thumbnails) with a real design-system primitive. cytario-web depends on this release: the context menus + the Badge defaults (PanelRow now relies on them).Notes