-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add support for keyboard shortcuts to <MenuItemLink>
#10790
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
25deb15
Add support for keyboard shortcuts to `<MenuItemLink>`
djhi 212100c
Don't lazy load KeyboardShortcut (tsc incompatibility)
djhi 9599edf
Move keyboard shortcuts code to ra-core
djhi caf750d
Improve documentation
djhi 5a4bb64
Merge branch 'next' into menu-item-keyboard-shortcuts
djhi 1a66cc1
Improve shortcut support
djhi 8f81a7d
Add shortcuts to simple example
djhi 0560b25
Fix tests
djhi eb48bad
Document the keyboardShortcutRepresentation prop
djhi eeb1502
Apply suggestions from code review
djhi 07445ad
Fix useHotkeys documentation link
djhi 1397d2e
Ensure React keys are unique
djhi e6a59e8
More stories
djhi 2d66154
Dim shortcut representation
djhi 88374b6
Fix MenuItemLink styles
djhi e242533
Add screenshots to documentation
djhi 707583e
Show shortcuts on hover only
djhi eb5452b
Fix tests
djhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
102 changes: 102 additions & 0 deletions
102
packages/ra-ui-materialui/src/KeyboardShortcut.stories.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import * as React from 'react'; | ||
| import { | ||
| createTheme, | ||
| List, | ||
| ListItem, | ||
| ListItemText, | ||
| Paper, | ||
| ThemeProvider, | ||
| } from '@mui/material'; | ||
| import { KeyboardShortcut } from './KeyboardShortcut'; | ||
| import { defaultTheme } from './theme'; | ||
|
|
||
| export default { | ||
| title: 'ra-ui-materialui/KeyboardShortcut', | ||
| }; | ||
|
|
||
| const Wrapper = ({ children }: { children: React.ReactNode }) => ( | ||
| <ThemeProvider theme={createTheme(defaultTheme)}> | ||
| <Paper sx={{ maxWidth: '60%', mx: 'auto', p: 2, mt: 2 }}> | ||
| {children} | ||
| </Paper> | ||
| </ThemeProvider> | ||
| ); | ||
|
|
||
| export const Default = () => ( | ||
| <Wrapper> | ||
| <List> | ||
| <ListItem | ||
| secondaryAction={<KeyboardShortcut keyboardShortcut="meta+K" />} | ||
| > | ||
| <ListItemText primary="meta and k" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={ | ||
| <KeyboardShortcut keyboardShortcut="shift+a" /> | ||
| } | ||
| > | ||
| <ListItemText primary="shift and a" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={<KeyboardShortcut keyboardShortcut="mod+B" />} | ||
| > | ||
| <ListItemText primary="mod and b" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={<KeyboardShortcut keyboardShortcut="alt+F" />} | ||
| > | ||
| <ListItemText primary="alt and f" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={ | ||
| <KeyboardShortcut keyboardShortcut="escape+F" /> | ||
| } | ||
| > | ||
| <ListItemText primary="escape and f" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={<KeyboardShortcut keyboardShortcut="esc+F" />} | ||
| > | ||
| <ListItemText primary="escape (written esc) and f" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={ | ||
| <KeyboardShortcut keyboardShortcut="shift+up" /> | ||
| } | ||
| > | ||
| <ListItemText primary="shift and up" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={<KeyboardShortcut keyboardShortcut="ctrl+d" />} | ||
| > | ||
| <ListItemText primary="ctrl and d" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={ | ||
| <KeyboardShortcut keyboardShortcut="meta+K>X" /> | ||
| } | ||
| > | ||
| <ListItemText primary="Meta and k then x" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={ | ||
| <KeyboardShortcut keyboardShortcut="space>a" /> | ||
| } | ||
| > | ||
| <ListItemText primary="Space then a" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={<KeyboardShortcut keyboardShortcut="g>g" />} | ||
| > | ||
| <ListItemText primary="g then g" /> | ||
| </ListItem> | ||
| <ListItem | ||
| secondaryAction={ | ||
| <KeyboardShortcut keyboardShortcut="ctrl+shift+a+c" /> | ||
| } | ||
| > | ||
| <ListItemText primary="ctrl and shift and a and c" /> | ||
| </ListItem> | ||
| </List> | ||
| </Wrapper> | ||
| ); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.