From 58accc9310637d0aeed983f0d3b3f245540b2c46 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Sun, 6 Nov 2022 20:14:53 +0100 Subject: [PATCH] feat: tweak toolbar shortcuts & remove library shortcut (#5832) --- src/components/Actions.tsx | 9 +- src/components/App.tsx | 12 - src/components/HelpDialog.tsx | 46 +- src/components/LibraryButton.tsx | 2 +- src/keys.ts | 11 + src/shapes.tsx | 16 +- .../regressionTests.test.tsx.snap | 456 +++++++++--------- src/tests/regressionTests.test.tsx | 2 +- 8 files changed, 291 insertions(+), 263 deletions(-) diff --git a/src/components/Actions.tsx b/src/components/Actions.tsx index 972c7ba8..75233d18 100644 --- a/src/components/Actions.tsx +++ b/src/components/Actions.tsx @@ -218,13 +218,12 @@ export const ShapesSwitcher = ({ appState: AppState; }) => ( <> - {SHAPES.map(({ value, icon, key, fillable }, index) => { - const numberKey = value === "eraser" ? 0 : index + 1; + {SHAPES.map(({ value, icon, key, numericKey, fillable }, index) => { const label = t(`toolBar.${value}`); const letter = key && (typeof key === "string" ? key : key[0]); const shortcut = letter - ? `${capitalizeString(letter)} ${t("helpDialog.or")} ${numberKey}` - : `${numberKey}`; + ? `${capitalizeString(letter)} ${t("helpDialog.or")} ${numericKey}` + : `${numericKey}`; return ( { this.setState({ isBindingEnabled: false }); } - if (event.code === CODES.ZERO) { - const nextState = this.toggleMenu("library"); - // track only openings - if (nextState) { - trackEvent( - "library", - "toggleLibrary (open)", - `keyboard (${this.device.isMobile ? "mobile" : "desktop"})`, - ); - } - } - if (isArrowKey(event.key)) { const step = (this.state.gridSize && diff --git a/src/components/HelpDialog.tsx b/src/components/HelpDialog.tsx index 96edf05f..1228cb91 100644 --- a/src/components/HelpDialog.tsx +++ b/src/components/HelpDialog.tsx @@ -1,6 +1,6 @@ import React from "react"; import { t } from "../i18n"; -import { isDarwin, isWindows } from "../keys"; +import { isDarwin, isWindows, KEYS } from "../keys"; import { Dialog } from "./Dialog"; import { getShortcutKey } from "../utils"; import "./HelpDialog.scss"; @@ -118,22 +118,42 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => { className="HelpDialog__island--tools" caption={t("helpDialog.tools")} > - - - - - - + + + + + + - - - + + void }) => { ]} isOr={false} /> - + +