Make the command bar button hotkey label update live
This commit is contained in:
@ -2,10 +2,22 @@ import { useCommandsContext } from 'hooks/useCommandsContext'
|
|||||||
import usePlatform from 'hooks/usePlatform'
|
import usePlatform from 'hooks/usePlatform'
|
||||||
import { hotkeyDisplay } from 'lib/hotkeyWrapper'
|
import { hotkeyDisplay } from 'lib/hotkeyWrapper'
|
||||||
import { COMMAND_PALETTE_HOTKEY } from './CommandBar/CommandBar'
|
import { COMMAND_PALETTE_HOTKEY } from './CommandBar/CommandBar'
|
||||||
|
import { KEYBINDING_CATEGORIES } from 'lib/constants'
|
||||||
|
import { useMemo } from 'react'
|
||||||
|
import { useInteractionMapContext } from 'hooks/useInteractionMapContext'
|
||||||
|
|
||||||
export function CommandBarOpenButton() {
|
export function CommandBarOpenButton() {
|
||||||
const { commandBarSend } = useCommandsContext()
|
|
||||||
const platform = usePlatform()
|
const platform = usePlatform()
|
||||||
|
const { commandBarSend } = useCommandsContext()
|
||||||
|
const { state: interactionMapState } = useInteractionMapContext()
|
||||||
|
|
||||||
|
const resolvedKeybinding = useMemo(
|
||||||
|
() =>
|
||||||
|
interactionMapState.context.overrides[
|
||||||
|
`${KEYBINDING_CATEGORIES.COMMAND_BAR}.toggle`
|
||||||
|
] || COMMAND_PALETTE_HOTKEY,
|
||||||
|
[interactionMapState.context.overrides]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
@ -15,7 +27,7 @@ export function CommandBarOpenButton() {
|
|||||||
>
|
>
|
||||||
<span>Commands</span>
|
<span>Commands</span>
|
||||||
<kbd className="bg-primary/10 dark:bg-chalkboard-80 dark:group-hover:bg-primary font-mono rounded-sm dark:text-inherit inline-block px-1 border-primary dark:border-chalkboard-90">
|
<kbd className="bg-primary/10 dark:bg-chalkboard-80 dark:group-hover:bg-primary font-mono rounded-sm dark:text-inherit inline-block px-1 border-primary dark:border-chalkboard-90">
|
||||||
{hotkeyDisplay(COMMAND_PALETTE_HOTKEY, platform)}
|
{hotkeyDisplay(resolvedKeybinding, platform)}
|
||||||
</kbd>
|
</kbd>
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user