From d2d6f0496ce816e9238e785ed3d0e7bd61b2483b Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sun, 26 Jun 2022 18:49:36 +1000 Subject: Refactor TileInfoModal Also change server info-response format to include sub-node common-names --- src/App.vue | 10 +- src/README.md | 2 +- src/components/TileInfoModal.vue | 240 ++++++++++++++++++--------------------- src/layout.ts | 2 +- src/lib.ts | 15 ++- 5 files changed, 129 insertions(+), 140 deletions(-) (limited to 'src') diff --git a/src/App.vue b/src/App.vue index 7576278..a3d0559 100644 --- a/src/App.vue +++ b/src/App.vue @@ -59,7 +59,8 @@ function getDefaultUiOpts(lytOpts: LayoutOptions): UiOptions { let screenSz = getBreakpoint(); // Reused option values let textColor = '#fafaf9'; - let bgColor = '#292524', bgColorLight = '#44403c', bgColorDark = '#1c1917', + let bgColor = '#292524', bgColorAlt = '#fafaf9', + bgColorLight = '#44403c', bgColorDark = '#1c1917', bgColorLight2 = '#57534e', bgColorDark2 = '#0e0c0b'; let altColor = '#a3e623', altColorDark = '#65a30d'; let accentColor = '#f59e0b'; @@ -69,6 +70,7 @@ function getDefaultUiOpts(lytOpts: LayoutOptions): UiOptions { // Shared coloring/sizing textColor, bgColor, + bgColorAlt, bgColorLight, bgColorDark, bgColorLight2, @@ -256,7 +258,7 @@ export default defineComponent({ let response = await fetch(urlPath); responseObj = await response.json(); } catch (error){ - console.log('ERROR loading tolnode data', error); + console.log('ERROR: Unable to retreive tol-node data', error); return false; } Object.getOwnPropertyNames(responseObj).forEach(n => {this.tolMap.set(n, responseObj[n])}); @@ -354,7 +356,7 @@ export default defineComponent({ let response = await fetch(urlPath); responseObj = await response.json(); } catch (error){ - console.log('ERROR loading tolnode data', error); + console.log('ERROR: Unable to retreive tol-node data', error); return false; } Object.getOwnPropertyNames(responseObj).forEach(n => {this.tolMap.set(n, responseObj[n])}); @@ -813,7 +815,7 @@ export default defineComponent({ let response = await fetch(urlPath); responseObj = await response.json(); } catch (error) { - console.log('ERROR: Unable to get tree data', error); + console.log('ERROR: Unable to retrieve tree data', error); return; } // Get root node name diff --git a/src/README.md b/src/README.md index dbd2ecb..6bf764c 100644 --- a/src/README.md +++ b/src/README.md @@ -2,7 +2,7 @@ - main.ts: Included by ../index.html. Creates the main Vue component. - App.vue: The main Vue component. - components: - - Tile.vue: Displays a tree-of-life node, and can include child nodes. + - Tile.vue: Displays a tree-of-life node. - TileInfoModal.vue: Modal displaying info about a Tile's node. - SearchModal.vue: Modal with a search bar. - SettingsModal: Modal displaying configurable settings. diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue index 90ad9a7..c8f8047 100644 --- a/src/components/TileInfoModal.vue +++ b/src/components/TileInfoModal.vue @@ -1,76 +1,66 @@ diff --git a/src/layout.ts b/src/layout.ts index 15c156b..79d3b70 100644 --- a/src/layout.ts +++ b/src/layout.ts @@ -308,7 +308,7 @@ let sqrLayout: LayoutFn = function (node, pos, dims, showHeader, allowCollapse, let numChildren = node.children.length; let areaAR = newDims[0] / newDims[1]; // Aspect ratio let lowestEmpSpc = Number.POSITIVE_INFINITY, usedNumCols = 0, usedNumRows = 0, usedTileSz = 0; - const MAX_TRIES = 20; // If there are many possibilities, skip some + const MAX_TRIES = 50; // If there are many possibilities, skip some let ptlNumCols = numChildren == 1 ? [1] : linspace(1, numChildren, Math.min(numChildren, MAX_TRIES)).map(n => Math.floor(n)); for (let numCols of ptlNumCols){ diff --git a/src/lib.ts b/src/lib.ts index 7841ac8..b3e6acc 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -48,11 +48,15 @@ export type ImgInfo = { license: string, artist: string, credit: string, -} -export type TileInfoResponse = { - tolNode: null | TolNode, - descData: null | DescInfo | [DescInfo, DescInfo], - imgData: null | ImgInfo | [ImgInfo, ImgInfo], +}; +export type NodeInfo = { + tolNode: TolNode, + descInfo: null | DescInfo, + imgInfo: null | ImgInfo, +}; +export type InfoResponse = { + nodeInfo: NodeInfo, + subNodesInfo: [] | [NodeInfo, NodeInfo], }; // Used by auto-mode and tutorial @@ -65,6 +69,7 @@ export type UiOptions = { // Shared coloring/sizing textColor: string, // CSS color bgColor: string, + bgColorAlt: string, bgColorLight: string, bgColorDark: string, bgColorLight2: string, -- cgit v1.2.3