Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add UI Primitives - FocusTrap, DismissableLayer, and Dialog. #1822

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

cpcramer
Copy link
Contributor

@cpcramer cpcramer commented Jan 16, 2025

What changed? Why?
Introduces new UI primitive components - FocusTrap, DismissableLayer, and Dialog.

FocusTrap:

  • Ensures keyboard focus remains within a contained area for accessibility

DismissableLayer:

  • Handles dismissal using outside clicks and escape key events

Dialog:

  • Portaling to document.body: Lets you render content (like modals, dialogs, or popups) outside of your component's normal DOM hierarchy. Avoids z-index and stacking context issues since the modal lives at the root. Prevents parent CSS from accidentally affecting your modal. Better for accessibility and screen readers. More semantic HTML structure
  • Focus management (trapping focus within dialog)
  • Click outside and escape key dismissal
  • Proper ARIA attributes for accessibility

Design Principles:

  • Limited styling
  • ARIA Accessibility built in
  • Optional props by default
  • Stand-alone primitive components

Updated WalletModal to use the primitives for:

  • Proper modal dialog behavior with ARIA attributes
  • Focus trapping for keyboard navigation
  • Click outside and escape key dismissal
  • Portal-based rendering

Notes to reviewers

How has it been tested?

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onchainkit-coverage ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 6:24pm
onchainkit-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 6:24pm
onchainkit-routes ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 6:24pm

@cpcramer cpcramer force-pushed the paul/add-ui-primitives branch from 0c5a293 to e2c339c Compare January 16, 2025 01:32
@cpcramer cpcramer force-pushed the paul/add-ui-primitives branch from 9221e1a to 408eb80 Compare January 16, 2025 02:00
@cpcramer cpcramer changed the title feat: Add UI Primitives 🚧 feat: Add UI Primitives Jan 16, 2025
@cpcramer cpcramer force-pushed the paul/add-ui-primitives branch from 7dff1e1 to c621053 Compare January 17, 2025 17:17
@cpcramer cpcramer force-pushed the paul/add-ui-primitives branch from c621053 to 87ed441 Compare January 17, 2025 17:38
@cpcramer cpcramer force-pushed the paul/add-ui-primitives branch from 87ed441 to 3e91e32 Compare January 17, 2025 18:16
@cpcramer cpcramer merged commit 92bc2a2 into main Jan 17, 2025
16 checks passed
@cpcramer cpcramer deleted the paul/add-ui-primitives branch January 17, 2025 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants