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

@@ -20,6 +20,7 @@ import QuickSettingsButton from './QuickSettingsButton'
import AccountMenuButton from './AccountMenuButton'
import StyledTooltip from '../StyledTooltip/StyledTooltip'
import UpgradeNow from './UpgradeNow'
import PreferencesButton from './PreferencesButton'
type Props = {
application: WebApplication
@@ -364,16 +365,7 @@ class Footer extends AbstractComponent<Props, State> {
/>
</div>
<div className="relative z-footer-bar-item select-none">
<StyledTooltip label="Open preferences">
<button
onClick={this.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>
<PreferencesButton openPreferences={this.openPreferences} />
</div>
<div className="relative z-footer-bar-item select-none">
<QuickSettingsButton

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

View File

@@ -18,6 +18,7 @@ const TagsSectionAddButton: FunctionComponent<Props> = ({ tags }) => {
() => keyboardStringForShortcut(commandService.keyboardShortcutForCommand(CREATE_NEW_TAG_COMMAND)),
[commandService],
)
return (
<IconButton
focusable={true}