♻️(frontend) remove redundant formatLongPressLabel helper
Use i18next interpolation directly in useShortcutFormatting
This commit is contained in:
@@ -14,7 +14,7 @@ export const formatShortcutLabel = (shortcut?: Shortcut) => {
|
|||||||
return parts.join('+')
|
return parts.join('+')
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-friendly label for a shortcut (reads “Control plus D”).
|
// SR-friendly label for a shortcut (reads "Control plus D").
|
||||||
export const formatShortcutLabelForSR = (
|
export const formatShortcutLabelForSR = (
|
||||||
shortcut: Shortcut | undefined,
|
shortcut: Shortcut | undefined,
|
||||||
{
|
{
|
||||||
@@ -57,12 +57,3 @@ export const getKeyLabelFromCode = (code?: string) => {
|
|||||||
if (code.startsWith('Arrow')) return code.slice(5) // Up, Down, Left, Right
|
if (code.startsWith('Arrow')) return code.slice(5) // Up, Down, Left, Right
|
||||||
return code
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
// Long-press label (visual or SR), e.g. “Hold V”.
|
|
||||||
export const formatLongPressLabel = (
|
|
||||||
codeLabel: string,
|
|
||||||
holdTemplate: string
|
|
||||||
) => {
|
|
||||||
if (!codeLabel) return holdTemplate.replace('{{key}}', '?')
|
|
||||||
return holdTemplate.replace('{{key}}', codeLabel)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { Shortcut } from '../types'
|
|||||||
import {
|
import {
|
||||||
formatShortcutLabel,
|
formatShortcutLabel,
|
||||||
formatShortcutLabelForSR,
|
formatShortcutLabelForSR,
|
||||||
formatLongPressLabel,
|
|
||||||
getKeyLabelFromCode,
|
getKeyLabelFromCode,
|
||||||
} from '../formatLabels'
|
} from '../formatLabels'
|
||||||
|
|
||||||
@@ -15,10 +14,7 @@ export const useShortcutFormatting = () => {
|
|||||||
(shortcut?: Shortcut, code?: string, kind?: string) => {
|
(shortcut?: Shortcut, code?: string, kind?: string) => {
|
||||||
if (code && kind === 'longPress') {
|
if (code && kind === 'longPress') {
|
||||||
const label = getKeyLabelFromCode(code)
|
const label = getKeyLabelFromCode(code)
|
||||||
return formatLongPressLabel(
|
return t('shortcutsPanel.visual.hold', { key: label || '?' })
|
||||||
label,
|
|
||||||
t('shortcutsPanel.visual.hold', { key: '{{key}}' })
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return formatShortcutLabel(shortcut)
|
return formatShortcutLabel(shortcut)
|
||||||
},
|
},
|
||||||
@@ -29,10 +25,7 @@ export const useShortcutFormatting = () => {
|
|||||||
(shortcut?: Shortcut, code?: string, kind?: string) => {
|
(shortcut?: Shortcut, code?: string, kind?: string) => {
|
||||||
if (code && kind === 'longPress') {
|
if (code && kind === 'longPress') {
|
||||||
const label = getKeyLabelFromCode(code)
|
const label = getKeyLabelFromCode(code)
|
||||||
return formatLongPressLabel(
|
return t('shortcutsPanel.sr.hold', { key: label || '?' })
|
||||||
label,
|
|
||||||
t('shortcutsPanel.sr.hold', { key: '{{key}}' })
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return formatShortcutLabelForSR(shortcut, {
|
return formatShortcutLabelForSR(shortcut, {
|
||||||
controlLabel: t('shortcutsPanel.sr.control'),
|
controlLabel: t('shortcutsPanel.sr.control'),
|
||||||
|
|||||||
Reference in New Issue
Block a user