From 4a9e686816507c36ec80b1a133a981089d7cca70 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Mon, 27 Jun 2022 01:41:18 +1000 Subject: Clean up code in SettingsModal Add reduced-versions of developer options Add input-range value indicators --- src/App.vue | 19 +-- src/components/SettingsModal.vue | 278 +++++++++++++++++++++------------------ src/components/Tile.vue | 10 +- 3 files changed, 160 insertions(+), 147 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1c80acf..887b9a1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -69,17 +69,9 @@ function getDefaultUiOpts(lytOpts: LayoutOptions): UiOptions { // return { // Shared coloring/sizing - textColor, - textColorAlt, - bgColor, - bgColorLight, - bgColorDark, - bgColorLight2, - bgColorDark2, - bgColorAlt, - bgColorAltDark, - altColor, - altColorDark, + textColor, textColorAlt, + bgColor, bgColorLight, bgColorDark, bgColorLight2, bgColorDark2, bgColorAlt, bgColorAltDark, + altColor, altColorDark, borderRadius: 5, // px shadowNormal: '0 0 2px black', shadowHovered: '0 0 1px 2px ' + altColor, @@ -660,6 +652,7 @@ export default defineComponent({ this.settingsOpen = true; }, async onSettingChg(setting: string){ + // Save in localStorage if (setting in this.lytOpts){ localStorage.setItem(lytOptPrefix + setting, String(this.lytOpts[setting as keyof LayoutOptions])); this.relayoutWithCollapse(); @@ -671,7 +664,7 @@ export default defineComponent({ } else { throw new Error('Unexpected setting'); } - console.log(`Saved ${setting}`) + console.log(`Saved setting ${setting}`); }, async onTreeChange(){ if (this.activeRoot != this.layoutTree){ @@ -683,6 +676,7 @@ export default defineComponent({ }, onResetSettings(): void { localStorage.clear(); + // Restore default options let defaultLytOpts = getDefaultLytOpts(); let defaultUiOpts = getDefaultUiOpts(defaultLytOpts); if (this.uiOpts.useReducedTree != defaultUiOpts.useReducedTree){ @@ -691,6 +685,7 @@ export default defineComponent({ Object.assign(this.lytOpts, defaultLytOpts); Object.assign(this.uiOpts, defaultUiOpts); console.log('Settings reset'); + // this.relayoutWithCollapse(); }, // For help events diff --git a/src/components/SettingsModal.vue b/src/components/SettingsModal.vue index a54fa58..83b42af 100644 --- a/src/components/SettingsModal.vue +++ b/src/components/SettingsModal.vue @@ -1,164 +1,182 @@ diff --git a/src/components/Tile.vue b/src/components/Tile.vue index 9983749..608938e 100644 --- a/src/components/Tile.vue +++ b/src/components/Tile.vue @@ -327,7 +327,7 @@ export default defineComponent({ watch: { // For setting transition state (allows external triggering, like via search and auto-mode) pos: { - handler(newVal, oldVal){ + handler(newVal: [number, number], oldVal: [number, number]){ let valChanged = newVal[0] != oldVal[0] || newVal[1] != oldVal[1]; if (valChanged && this.uiOpts.transitionDuration > 100 && !this.inTransition){ this.inTransition = true; @@ -336,7 +336,7 @@ export default defineComponent({ deep: true, }, dims: { - handler(newVal, oldVal){ + handler(newVal: [number, number], oldVal: [number, number]){ let valChanged = newVal[0] != oldVal[0] || newVal[1] != oldVal[1]; if (valChanged && this.uiOpts.transitionDuration > 100 && !this.inTransition){ this.inTransition = true; @@ -349,7 +349,7 @@ export default defineComponent({ this.triggerAnimation(this.isLeaf ? 'animate-expand-shrink' : 'animate-shrink-expand'); }, // Scroll to focused child if overflownRoot - hasFocusedChild(newVal, oldVal){ + hasFocusedChild(newVal: boolean, oldVal: boolean){ if (newVal && this.isOverflownRoot){ let focusedChild = this.layoutNode.children.find(n => n.hasFocus)! let bottomY = focusedChild.pos[1] + focusedChild.dims[1] + this.lytOpts.tileSpacing; @@ -358,14 +358,14 @@ export default defineComponent({ } }, // Allow overflow temporarily after being unhidden - hidden(newVal, oldVal){ + hidden(newVal: boolean, oldVal: boolean){ if (oldVal && !newVal){ this.justUnhidden = true; setTimeout(() => {this.justUnhidden = false;}, this.uiOpts.transitionDuration); } }, // Used to 'flash' the tile when focused - hasFocus(newVal, oldVal){ + hasFocus(newVal: boolean, oldVal: boolean){ if (newVal != oldVal && newVal){ this.inFlash = true; setTimeout(() => {this.inFlash = false;}, this.uiOpts.transitionDuration); -- cgit v1.2.3