diff --git a/src/actions/actionMenu.tsx b/src/actions/actionMenu.tsx
index 8cfae3981..b71e3122a 100644
--- a/src/actions/actionMenu.tsx
+++ b/src/actions/actionMenu.tsx
@@ -7,6 +7,7 @@ import { register } from "./register";
import { allowFullScreen, exitFullScreen, isFullScreen } from "../utils";
import { CODES, KEYS } from "../keys";
import { HelpIcon } from "../components/HelpIcon";
+import { MiniMap } from "../components/MiniMap";
export const actionToggleCanvasMenu = register({
name: "toggleCanvasMenu",
@@ -84,3 +85,21 @@ export const actionShortcuts = register({
),
keyTest: (event) => event.key === KEYS.QUESTION_MARK,
});
+
+export const actionMinimap = register({
+ name: "toggleMinimap",
+ perform: (_elements, appState) => {
+ return {
+ appState: {
+ ...appState,
+ isMinimapEnabled: !appState.isMinimapEnabled,
+ },
+ commitToHistory: false,
+ };
+ },
+ PanelComponent: ({ appState, elements }) =>
+ appState.isMinimapEnabled ? (
+
+ ) : null,
+ keyTest: (event) => event.key === KEYS.M,
+});
diff --git a/src/actions/index.ts b/src/actions/index.ts
index b335e44e6..52492692e 100644
--- a/src/actions/index.ts
+++ b/src/actions/index.ts
@@ -44,6 +44,7 @@ export {
actionToggleEditMenu,
actionFullScreen,
actionShortcuts,
+ actionMinimap,
} from "./actionMenu";
export { actionGroup, actionUngroup } from "./actionGroup";
diff --git a/src/actions/types.ts b/src/actions/types.ts
index 9d90efd88..e315d0feb 100644
--- a/src/actions/types.ts
+++ b/src/actions/types.ts
@@ -85,7 +85,8 @@ export type ActionName =
| "alignHorizontallyCentered"
| "distributeHorizontally"
| "distributeVertically"
- | "viewMode";
+ | "viewMode"
+ | "toggleMinimap";
export interface Action {
name: ActionName;
diff --git a/src/appState.ts b/src/appState.ts
index f77e6cffa..3598ac1cb 100644
--- a/src/appState.ts
+++ b/src/appState.ts
@@ -73,6 +73,7 @@ export const getDefaultAppState = (): Omit<
zenModeEnabled: false,
zoom: { value: 1 as NormalizedZoomValue, translation: { x: 0, y: 0 } },
viewModeEnabled: false,
+ isMinimapEnabled: false,
};
};
@@ -153,6 +154,7 @@ const APP_STATE_STORAGE_CONF = (<
zenModeEnabled: { browser: true, export: false },
zoom: { browser: true, export: false },
viewModeEnabled: { browser: false, export: false },
+ isMinimapEnabled: { browser: true, export: false },
});
const _clearAppStateForStorage = (
diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx
index bfc95e405..6f5482655 100644
--- a/src/components/LayerUI.tsx
+++ b/src/components/LayerUI.tsx
@@ -41,7 +41,6 @@ import Stack from "./Stack";
import { ToolButton } from "./ToolButton";
import { Tooltip } from "./Tooltip";
import { UserList } from "./UserList";
-import { MiniMap } from "./MiniMap";
interface LayerUIProps {
actionManager: ActionManager;
@@ -603,7 +602,7 @@ const LayerUI = ({
>
{renderCustomFooter?.(false)}
{actionManager.renderAction("toggleShortcuts")}
-
+ {actionManager.renderAction("toggleMinimap")}