From 0c3d34261ec5480bdbb647c501445d5e254cac1d Mon Sep 17 00:00:00 2001 From: Lipis Date: Tue, 7 Apr 2020 14:39:06 +0300 Subject: [PATCH] Fixes in Shortcuts dialog and minor refactor (#1297) --- src/actions/actionCanvas.tsx | 4 +- src/actions/actionDuplicateSelection.tsx | 2 +- src/actions/actionZindex.tsx | 8 +- src/components/Actions.tsx | 11 ++- src/components/HelpIcon.tsx | 6 +- src/components/LockIcon.tsx | 3 +- src/components/ShortcutsDialog.tsx | 121 +++++++++++++---------- src/components/ToolButton.tsx | 2 + src/locales/en.json | 1 + src/tests/queries/toolQueries.ts | 14 +-- src/utils.ts | 6 +- 11 files changed, 96 insertions(+), 82 deletions(-) diff --git a/src/actions/actionCanvas.tsx b/src/actions/actionCanvas.tsx index a6dc57fa..a819a17b 100644 --- a/src/actions/actionCanvas.tsx +++ b/src/actions/actionCanvas.tsx @@ -90,7 +90,7 @@ export const actionZoomIn = register({ { updateData(null); @@ -117,7 +117,7 @@ export const actionZoomOut = register({ { updateData(null); diff --git a/src/actions/actionDuplicateSelection.tsx b/src/actions/actionDuplicateSelection.tsx index 61b4d206..5ab54e5b 100644 --- a/src/actions/actionDuplicateSelection.tsx +++ b/src/actions/actionDuplicateSelection.tsx @@ -38,7 +38,7 @@ export const actionDuplicateSelection = register({ updateData(null)} - title={`${t("labels.sendBackward")} ${getShortcutKey("CtrlOrCmd+[")}`} + title={`${t("labels.sendBackward")} — ${getShortcutKey("CtrlOrCmd+[")}`} > {sendBackward} @@ -116,7 +116,7 @@ export const actionBringForward = register({ type="button" className="zIndexButton" onClick={() => updateData(null)} - title={`${t("labels.bringForward")} ${getShortcutKey("CtrlOrCmd+]")}`} + title={`${t("labels.bringForward")} — ${getShortcutKey("CtrlOrCmd+]")}`} > {bringForward} @@ -145,7 +145,7 @@ export const actionSendToBack = register({ type="button" className="zIndexButton" onClick={() => updateData(null)} - title={`${t("labels.sendToBack")} ${ + title={`${t("labels.sendToBack")} — ${ isDarwin ? getShortcutKey("CtrlOrCmd+Alt+[") : getShortcutKey("CtrlOrCmd+Shift+[") @@ -178,7 +178,7 @@ export const actionBringToFront = register({ type="button" className="zIndexButton" onClick={(event) => updateData(null)} - title={`${t("labels.bringToFront")} ${ + title={`${t("labels.bringToFront")} — ${ isDarwin ? getShortcutKey("CtrlOrCmd+Alt+]") : getShortcutKey("CtrlOrCmd+Shift+]") diff --git a/src/components/Actions.tsx b/src/components/Actions.tsx index 827989d5..44f74982 100644 --- a/src/components/Actions.tsx +++ b/src/components/Actions.tsx @@ -6,7 +6,7 @@ import { hasBackground, hasStroke, hasText, getTargetElement } from "../scene"; import { t } from "../i18n"; import { SHAPES } from "../shapes"; import { ToolButton } from "./ToolButton"; -import { capitalizeString, getShortcutKey, setCursorForShape } from "../utils"; +import { capitalizeString, setCursorForShape } from "../utils"; import Stack from "./Stack"; import useIsMobile from "../is-mobile"; @@ -94,9 +94,9 @@ export function ShapesSwitcher({ <> {SHAPES.map(({ value, icon }, index) => { const label = t(`toolBar.${value}`); - const shortcut = getShortcutKey( - `${capitalizeString(value)[0]}, ${index + 1}`, - ); + const shortcut = `${capitalizeString(value)[0]} ${t( + "shortcutsDialog.or", + )} ${index + 1}`; return ( { setAppState({ elementType: value, diff --git a/src/components/HelpIcon.tsx b/src/components/HelpIcon.tsx index 5e700834..d5ed178b 100644 --- a/src/components/HelpIcon.tsx +++ b/src/components/HelpIcon.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { getShortcutKey } from "../utils"; type HelpIconProps = { title?: string; @@ -21,10 +20,7 @@ const ICON = ( export function HelpIcon(props: HelpIconProps) { return ( -