feat: add the Collapsible primitive#12
Open
ivanbanov wants to merge 2 commits into
Open
Conversation
Adds @dunky.dev/collapsible (framework-free machine) and @dunky.dev/react-collapsible with the Collapsible root plus Collapsible.Trigger and Collapsible.Content parts. A disclosure that toggles a content region: the content stays mounted while closed, disabled gates user toggling while the trigger stays focusable, and controlled open follows the prop and reports toggles through onOpenChange. 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 Collapsible primitive as two packages:
@dunky.dev/collapsible— the framework-free core: a state machine (built on@dunky.dev/state-machine) with two states,openandclosed, plus aconnectthat translates state into the agnostic bindings vocabulary.@dunky.dev/react-collapsible— the thin React binding rendering the compound parts.A collapsible is a disclosure following the WAI-ARIA APG Disclosure (Show/Hide) pattern: a trigger that shows and hides an associated content region in place. State is exposed controlled (
open, follow + report, matching the dialog's contract) and uncontrolled (defaultOpen), with every transition reported throughonOpenChange. Includes a changeset (minorfor both packages).Anatomy
Behavior
<button>carryingaria-expandedand a constantaria-controlsreference to the content; Enter/Space activation is native button semantics.hiddenattribute plusaria-hidden— so the ARIA reference never dangles anddata-statecan drive open/close animations.aria-disabledinstead of dropping out of the tab order; programmatic and controlled open/close stay ungated.data-state(open/closed) anddata-disabled— the styling and animation hooks.Test plan
pnpm test:ci— 9 files, 101 tests passingpnpm typecheckpnpm lintpnpm format:checkpnpm build🤖 Generated with Claude Code