feat: Show preferences keyboard shortcut in tooltip

This commit is contained in:
Aman Harwara
2022-12-05 13:37:21 +05:30
parent 7c261af230
commit 8575b3e714
3 changed files with 33 additions and 10 deletions

View File

@@ -0,0 +1,30 @@
import { keyboardStringForShortcut, OPEN_PREFERENCES_COMMAND } from '@standardnotes/ui-services'
import { useMemo } from 'react'
import { useCommandService } from '../CommandProvider'
import Icon from '../Icon/Icon'
import StyledTooltip from '../StyledTooltip/StyledTooltip'
type Props = {
openPreferences: () => void
}
const PreferencesButton = ({ openPreferences }: Props) => {
const commandService = useCommandService()
const shortcut = useMemo(
() => keyboardStringForShortcut(commandService.keyboardShortcutForCommand(OPEN_PREFERENCES_COMMAND)),
[commandService],
)
return (
<StyledTooltip label={`Open preferences (${shortcut})`}>
<button onClick={openPreferences} className="flex h-full w-8 cursor-pointer items-center justify-center">
<div className="h-5">
<Icon type="tune" className="rounded hover:text-info" />
</div>
</button>
</StyledTooltip>
)
}
export default PreferencesButton