-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(command-bar): add shortcut help (#18810)
- Loading branch information
1 parent
1e67eb3
commit 573487e
Showing
7 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
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 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 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 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,23 @@ | ||
import { useMountedLogic } from 'kea' | ||
|
||
import { KeyboardShortcut } from '~/layout/navigation-3000/components/KeyboardShortcut' | ||
import { shortcutsLogic } from './shortcutsLogic' | ||
|
||
export const Shortcuts = (): JSX.Element => { | ||
useMountedLogic(shortcutsLogic) | ||
|
||
return ( | ||
<div className="flex flex-col h-full p-5"> | ||
<h3>Keyboard shortcuts</h3> | ||
<h4>Site-wide shortcuts</h4> | ||
<div className="space-y-1"> | ||
<div> | ||
<KeyboardShortcut command k /> Open search | ||
</div> | ||
<div> | ||
<KeyboardShortcut command shift k /> Open command palette | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains 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 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,26 @@ | ||
import { kea, path, connect, afterMount, beforeUnmount } from 'kea' | ||
|
||
import { commandBarLogic } from './commandBarLogic' | ||
|
||
import type { shortcutsLogicType } from './shortcutsLogicType' | ||
|
||
export const shortcutsLogic = kea<shortcutsLogicType>([ | ||
path(['lib', 'components', 'CommandBar', 'shortcutsLogic']), | ||
connect({ | ||
actions: [commandBarLogic, ['hideCommandBar']], | ||
}), | ||
afterMount(({ actions, cache }) => { | ||
// register keyboard shortcuts | ||
cache.onKeyDown = (event: KeyboardEvent) => { | ||
if (event.key === 'Escape') { | ||
// hide command bar | ||
actions.hideCommandBar() | ||
} | ||
} | ||
window.addEventListener('keydown', cache.onKeyDown) | ||
}), | ||
beforeUnmount(({ cache }) => { | ||
// unregister keyboard shortcuts | ||
window.removeEventListener('keydown', cache.onKeyDown) | ||
}), | ||
]) |
This file contains 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