feat(react): add the Drawer primitive#19
Open
ivanbanov wants to merge 2 commits into
Open
Conversation
Adds @dunky.dev/drawer (framework-free machine) and @dunky.dev/react-drawer (React binding). Anatomy: Drawer root with Trigger, Portal, Backdrop, Viewport, Content, Title, Description, and Close. A modal panel that slides in from a screen edge — the dialog contract (focus trap, scroll lock, Escape/outside-press dismissal, layer stacking, controlled open) plus a placement option surfaced as a data-placement styling hook. 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 Drawer primitive across both scopes:
@dunky.dev/drawer(packages/core/drawer) — the framework-free state machine carrying all behavior.@dunky.dev/react-drawer(packages/react/drawer) — the thin React binding, stories, and tests.A drawer is a modal panel that slides in from a screen edge — semantically a dialog with a
placement(left | right | top | bottom, defaultright). Placement is pure configuration: it never gates behavior and rides along as adata-placementstyling hook on the visual layers next todata-state, so slide animations key off attributes. Always modal in v0 — nomodal/roleswitch; snap points and swipe gestures are out of scope by decision.Anatomy
Drawer— root; owns the machine and the open/close contractDrawer.Trigger— button that toggles the drawerDrawer.Portal— reparents the visual layers to the document bodyDrawer.Backdrop— dimming layer behind the panelDrawer.Viewport— positioning surface for the panelDrawer.Content— the panel itself (role="dialog")Drawer.Title/Drawer.Description— accessible name and descriptionDrawer.Close— button that closes the drawerBehavior
opencontract: a controlled drawer reports every open/close intent throughonOpenChangebut only moves when the prop changes — ignoring a report is a working veto.role="dialog",aria-modal,aria-labelledby/aria-describedbywired to Title/Description; trigger carriesaria-haspopup,aria-expanded, andaria-controls.data-state="open | closed"everywhere, plusdata-placementon Backdrop, Viewport, and Content.Test plan
pnpm test:ci— 13 files, 162 tests passingpnpm typecheckpnpm lintpnpm format:checkpnpm build🤖 Generated with Claude Code