Skip to content

Commit 35f464a

Browse files
ryan-williamsclaude
andcommitted
Add comprehensive docstrings to modal components
- ShortcutsModal: Describe group organization, editable bindings, conflict detection - Omnibar: Explain fuzzy search, keyboard navigation, sequence support - SequenceModal: Document auto-appearance, completions, timeout behavior Each docstring explains how the component differs from the others. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d4e9900 commit 35f464a

File tree

3 files changed

+65
-12
lines changed

3 files changed

+65
-12
lines changed

src/Omnibar.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,31 @@ function BindingBadge({ binding }: { binding: string }) {
9696
}
9797

9898
/**
99-
* Omnibar/command palette component for searching and executing actions.
99+
* Command palette for searching and executing actions by name.
100100
*
101-
* Uses CSS classes from styles.css. Override via CSS custom properties:
102-
* --kbd-bg, --kbd-text, --kbd-accent, etc.
101+
* Opens by default with `⌘K` (macOS) or `Ctrl+K` (Windows/Linux). Type to search
102+
* across all registered actions by label, then press Enter to execute.
103+
*
104+
* Features:
105+
* - **Fuzzy search**: Matches action labels (e.g., "nav tab" finds "Navigate to Table")
106+
* - **Keyboard navigation**: Arrow keys to select, Enter to execute, Escape to close
107+
* - **Binding display**: Shows keyboard shortcuts next to each result
108+
* - **Sequence support**: Can also match and execute key sequences
109+
*
110+
* Unlike ShortcutsModal (shows all shortcuts organized by group) or LookupModal
111+
* (type keys to filter by binding), Omnibar is search-first by action name/label.
112+
*
113+
* Styled via CSS custom properties: --kbd-bg, --kbd-text, --kbd-accent, etc.
103114
*
104115
* @example
105116
* ```tsx
117+
* // Basic usage with HotkeysProvider (recommended)
118+
* <HotkeysProvider>
119+
* <App />
120+
* <Omnibar />
121+
* </HotkeysProvider>
122+
*
123+
* // Standalone with explicit props
106124
* <Omnibar
107125
* actions={ACTIONS}
108126
* handlers={HANDLERS}

src/SequenceModal.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@ import { useHotkeysContext } from './HotkeysProvider'
33
import type { SequenceCompletion } from './types'
44
import { formatCombination } from './utils'
55

6+
/**
7+
* Modal that appears during multi-key sequence input (e.g., `g t` for "go to table").
8+
*
9+
* When a user presses a key that starts a sequence, this modal appears showing:
10+
* - The keys pressed so far
11+
* - Available completions (what keys can come next)
12+
* - A timeout indicator
13+
*
14+
* Unlike LookupModal (which requires explicit activation and lets you browse/search),
15+
* SequenceModal appears automatically when you start typing a sequence and auto-executes
16+
* when a complete sequence is entered.
17+
*
18+
* The modal auto-dismisses if no completion is pressed within the sequence timeout,
19+
* or when the user presses Escape, or when a complete sequence is executed.
20+
*
21+
* @example
22+
* ```tsx
23+
* // Include in your app (no props needed - uses HotkeysContext)
24+
* <HotkeysProvider>
25+
* <App />
26+
* <SequenceModal />
27+
* </HotkeysProvider>
28+
* ```
29+
*/
630
export function SequenceModal() {
731
const {
832
pendingKeys,

src/ShortcutsModal.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,20 +392,31 @@ function BindingDisplay({
392392
}
393393

394394
/**
395-
* Modal component for displaying and optionally editing keyboard shortcuts.
395+
* Modal for displaying all keyboard shortcuts, organized by group.
396396
*
397-
* Uses CSS classes from styles.css. Override via CSS custom properties:
398-
* --kbd-bg, --kbd-text, --kbd-kbd-bg, etc.
397+
* Opens by default with `?` key. Shows all registered actions and their bindings,
398+
* grouped by category (e.g., "Navigation", "Edit", "Global").
399+
*
400+
* Features:
401+
* - **Editable bindings**: Click any shortcut to rebind it (when `editable` is true)
402+
* - **Conflict detection**: Warns when a binding conflicts with existing shortcuts
403+
* - **Custom group renderers**: Use `groupRenderers` for custom layouts (e.g., two-column for fwd/back pairs)
404+
* - **Persistence**: Integrates with HotkeysProvider's localStorage persistence
405+
*
406+
* Unlike Omnibar (search-first) or LookupModal (type keys to filter), ShortcutsModal
407+
* shows everything at once in a browsable, organized view.
408+
*
409+
* Styled via CSS custom properties: --kbd-bg, --kbd-text, --kbd-kbd-bg, etc.
399410
*
400411
* @example
401412
* ```tsx
402-
* // Read-only display
403-
* <ShortcutsModal
404-
* keymap={HOTKEYS}
405-
* labels={{ 'metric:temp': 'Temperature' }}
406-
* />
413+
* // Basic usage with HotkeysProvider (recommended)
414+
* <HotkeysProvider>
415+
* <App />
416+
* <ShortcutsModal editable />
417+
* </HotkeysProvider>
407418
*
408-
* // Editable with callbacks
419+
* // Standalone with explicit props
409420
* <ShortcutsModal
410421
* keymap={keymap}
411422
* defaults={DEFAULT_KEYMAP}

0 commit comments

Comments
 (0)