From 84d5015db336055868645ebe2605f6a54598c878 Mon Sep 17 00:00:00 2001 From: Mark Mankarious Date: Wed, 18 Oct 2023 11:47:58 +0100 Subject: [PATCH] refactor: renames main menu options for better handling --- docs/pages/docs/api/index.mdx | 4 ++-- docs/pages/docs/api/initialScene.mdx | 3 ++- src/components/MainMenu/MainMenu.tsx | 24 ++++++++++++------------ src/config.ts | 12 ++++++------ src/stores/uiStateStore.tsx | 3 +-- src/types/common.ts | 12 ++++++------ 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/pages/docs/api/index.mdx b/docs/pages/docs/api/index.mdx index d96371d..a786c26 100644 --- a/docs/pages/docs/api/index.mdx +++ b/docs/pages/docs/api/index.mdx @@ -7,5 +7,5 @@ | `height` | `number` \| `string` | Height of the Isoflow renderer as a CSS value. | `100%` | | `onSceneUpdate` | `function` | A callback that is triggered whenever an item is added, updated or removed from the scene. The callback is called with the updated scene as the first argument. | `undefined` | | `enableDebugTools` | `boolean` | Enables extra tools for debugging purposes. | `false` | -| `editorMode` | `EXPLORABLE_READONLY` \| `NON_INTERACTIVE` \| `EDITABLE` | Enables / disables editor features. | `EDITABLE` | -| `mainMenuOptions` | `(OPEN \| SAVE_JSON \| CLEAR \| GITHUB \| DISCORD \| VERSION)[]` | Shows / hides options in the main menu. If `[]` is passed, the menu is hidden. | `['OPEN', 'SAVE_JSON', 'CLEAR', 'GITHUB', 'DISCORD', 'VERSION']` | \ No newline at end of file +| `editorMode` | `"EXPLORABLE_READONLY"` \| `"NON_INTERACTIVE"` \| `"EDITABLE"` | Enables / disables editor features. | `"EDITABLE"` | +| `mainMenuOptions` | `("ACTION.OPEN" \| "EXPORT.JSON" \| "EXPORT.PNG" \| "ACTION.CLEAR_CANVAS" \| "LINK.GITHUB" \| "LINK.DISCORD" \| "VERSION")[]` | Shows / hides options in the main menu. If `[]` is passed, the menu is hidden. | All enabled | \ No newline at end of file diff --git a/docs/pages/docs/api/initialScene.mdx b/docs/pages/docs/api/initialScene.mdx index 5889c6a..ae11ca1 100644 --- a/docs/pages/docs/api/initialScene.mdx +++ b/docs/pages/docs/api/initialScene.mdx @@ -4,13 +4,14 @@ The `initialScene` object contains the following properties: | Name | Type | Default | | --- | --- | --- | +| `title` | `string` | `undefined` | | `icons` | [`Icon[]`](#icon) | `[]` | | `nodes` | [`Node[]`](#node) | `[]` | | `connectors` | [`Connector[]`](#connector) | `[]` | | `rectangles` | [`Rectangle[]`](#rectangle) | `[]` | | `textBoxes` | [`TextBox[]`](#textbox) | `[]` | -| `title` | `string` | `undefined` | | `zoom` | `number` | `1` | +| `scroll` | `Coords` | `{ x: 0, y: 0 }` | ## `Icon` diff --git a/src/components/MainMenu/MainMenu.tsx b/src/components/MainMenu/MainMenu.tsx index ebc5631..b5007d0 100644 --- a/src/components/MainMenu/MainMenu.tsx +++ b/src/components/MainMenu/MainMenu.tsx @@ -100,14 +100,14 @@ export const MainMenu = () => { const sectionVisibility = useMemo(() => { return { actions: Boolean( - mainMenuOptions.includes('OPEN') || - mainMenuOptions.includes('EXPORT_JSON') || - mainMenuOptions.includes('EXPORT_PNG') || - mainMenuOptions.includes('CLEAR_CANVAS') + mainMenuOptions.find((opt) => { + return opt.includes('ACTION') || opt.includes('EXPORT'); + }) ), links: Boolean( - mainMenuOptions.includes('GITHUB') || - mainMenuOptions.includes('DISCORD') + mainMenuOptions.find((opt) => { + return opt.includes('LINK'); + }) ), version: Boolean(mainMenuOptions.includes('VERSION')) }; @@ -139,25 +139,25 @@ export const MainMenu = () => { }} > - {mainMenuOptions.includes('OPEN') && ( + {mainMenuOptions.includes('ACTION.OPEN') && ( }> Open )} - {mainMenuOptions.includes('EXPORT_JSON') && ( + {mainMenuOptions.includes('EXPORT.JSON') && ( }> Export as JSON )} - {mainMenuOptions.includes('EXPORT_PNG') && ( + {mainMenuOptions.includes('EXPORT.PNG') && ( }> Export as image )} - {mainMenuOptions.includes('CLEAR_CANVAS') && ( + {mainMenuOptions.includes('ACTION.CLEAR_CANVAS') && ( }> Clear the canvas @@ -167,7 +167,7 @@ export const MainMenu = () => { <> - {mainMenuOptions.includes('GITHUB') && ( + {mainMenuOptions.includes('LINK.GITHUB') && ( { return gotoUrl(`${REPOSITORY_URL}`); @@ -178,7 +178,7 @@ export const MainMenu = () => { )} - {mainMenuOptions.includes('DISCORD') && ( + {mainMenuOptions.includes('LINK.DISCORD') && ( { return gotoUrl('https://discord.gg/QYPkvZth7D'); diff --git a/src/config.ts b/src/config.ts index 0d30ce7..86b6cfc 100644 --- a/src/config.ts +++ b/src/config.ts @@ -60,11 +60,11 @@ export const INITIAL_SCENE: SceneInput = { rectangles: [] }; export const MAIN_MENU_OPTIONS: MainMenuOptions = [ - 'OPEN', - 'EXPORT_JSON', - 'EXPORT_PNG', - 'CLEAR_CANVAS', - 'DISCORD', - 'GITHUB', + 'ACTION.OPEN', + 'EXPORT.JSON', + 'EXPORT.PNG', + 'ACTION.CLEAR_CANVAS', + 'LINK.DISCORD', + 'LINK.GITHUB', 'VERSION' ]; diff --git a/src/stores/uiStateStore.tsx b/src/stores/uiStateStore.tsx index bdfa3c7..661834b 100644 --- a/src/stores/uiStateStore.tsx +++ b/src/stores/uiStateStore.tsx @@ -5,10 +5,9 @@ import { incrementZoom, decrementZoom, getStartingMode, - getTilePosition, getTileScrollPosition } from 'src/utils'; -import { UiStateStore, Coords } from 'src/types'; +import { UiStateStore } from 'src/types'; const initialState = () => { return createStore((set, get) => { diff --git a/src/types/common.ts b/src/types/common.ts index c26ea5b..d708925 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -32,12 +32,12 @@ export const EditorModeEnum = { } as const; export const MainMenuOptionsEnum = { - OPEN: 'OPEN', - EXPORT_JSON: 'EXPORT_JSON', - EXPORT_PNG: 'EXPORT_PNG', - CLEAR_CANVAS: 'CLEAR_CANVAS', - GITHUB: 'GITHUB', - DISCORD: 'DISCORD', + 'ACTION.OPEN': 'ACTION.OPEN', + 'EXPORT.JSON': 'EXPORT.JSON', + 'EXPORT.PNG': 'EXPORT.PNG', + 'ACTION.CLEAR_CANVAS': 'ACTION.CLEAR_CANVAS', + 'LINK.GITHUB': 'LINK.GITHUB', + 'LINK.DISCORD': 'LINK.DISCORD', VERSION: 'VERSION' } as const;