From e4c154f43e7aad2babe65c0d945f9e2a9958e7b6 Mon Sep 17 00:00:00 2001 From: Mohit kumar Bajoria Date: Tue, 7 Apr 2020 16:12:10 +0530 Subject: [PATCH] Button for shortcuts (#1253) --- src/actions/actionMenu.tsx | 18 ++++++++++++++++++ src/actions/index.ts | 1 + src/actions/types.ts | 3 ++- src/components/HelpIcon.tsx | 31 +++++++++++++++++++++++++++++++ src/components/LayerUI.tsx | 1 + src/locales/en.json | 3 ++- src/styles.scss | 17 +++++++++++++++-- 7 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 src/components/HelpIcon.tsx diff --git a/src/actions/actionMenu.tsx b/src/actions/actionMenu.tsx index 844e951f..0458778c 100644 --- a/src/actions/actionMenu.tsx +++ b/src/actions/actionMenu.tsx @@ -6,6 +6,7 @@ import { showSelectedShapeActions } from "../element"; import { register } from "./register"; import { allowFullScreen, exitFullScreen, isFullScreen } from "../utils"; import { KEYS } from "../keys"; +import { HelpIcon } from "../components/HelpIcon"; export const actionToggleCanvasMenu = register({ name: "toggleCanvasMenu", @@ -63,3 +64,20 @@ export const actionFullScreen = register({ }, keyTest: (event) => event.keyCode === KEYS.F_KEY_CODE, }); + +export const actionShortcuts = register({ + name: "toggleShortcuts", + perform: (_elements, appState) => { + return { + appState: { + ...appState, + showShortcutsDialog: true, + }, + commitToHistory: false, + }; + }, + PanelComponent: ({ updateData }) => ( + + ), + keyTest: (event) => event.key === KEYS.QUESTION_MARK, +}); diff --git a/src/actions/index.ts b/src/actions/index.ts index 7680cbdf..6e27bdd6 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -40,4 +40,5 @@ export { actionToggleCanvasMenu, actionToggleEditMenu, actionFullScreen, + actionShortcuts, } from "./actionMenu"; diff --git a/src/actions/types.ts b/src/actions/types.ts index 786477bd..91d8a051 100644 --- a/src/actions/types.ts +++ b/src/actions/types.ts @@ -49,7 +49,8 @@ export type ActionName = | "zoomOut" | "resetZoom" | "changeFontFamily" - | "toggleFullScreen"; + | "toggleFullScreen" + | "toggleShortcuts"; export interface Action { name: ActionName; diff --git a/src/components/HelpIcon.tsx b/src/components/HelpIcon.tsx new file mode 100644 index 00000000..5e700834 --- /dev/null +++ b/src/components/HelpIcon.tsx @@ -0,0 +1,31 @@ +import React from "react"; +import { getShortcutKey } from "../utils"; + +type HelpIconProps = { + title?: string; + name?: string; + id?: string; + onClick?(): void; +}; + +const ICON = ( + + + +); + +export function HelpIcon(props: HelpIconProps) { + return ( + + ); +} diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index fdca0215..41e689f0 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -202,6 +202,7 @@ export const LayerUI = React.memo( languages={languages} floating /> + {actionManager.renderAction("toggleShortcuts")} {appState.scrolledOutside && (