From 629b9208503369c3f20ceb59685ef49766344093 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sun, 29 Jan 2023 12:21:55 +1100 Subject: Adjust frontend coding style Add line spacing and section comments Fix 'Last updated' line in help modal being shown despite overflow --- src/components/SettingsModal.vue | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/components/SettingsModal.vue') diff --git a/src/components/SettingsModal.vue b/src/components/SettingsModal.vue index a55dc41..95721e2 100644 --- a/src/components/SettingsModal.vue +++ b/src/components/SettingsModal.vue @@ -5,6 +5,7 @@

Settings

+

Timing

@@ -24,6 +25,7 @@
{{store.autoActionDelay}} ms
+

Layout

@@ -76,6 +78,7 @@
{{store.lytOpts.tileSpacing}} px
+

Other

@@ -102,10 +105,12 @@ @change="onSettingChg('disableShortcuts')"/> Disable keyboard shortcuts
+ Reset +
Saved
@@ -117,28 +122,27 @@ import {ref, computed, watch} from 'vue'; import SButton from './SButton.vue'; import CloseIcon from './icon/CloseIcon.vue'; -import {useStore, StoreState} from '../store'; +import {useStore} from '../store'; -// Refs const rootRef = ref(null as HTMLDivElement | null); const closeRef = ref(null as typeof CloseIcon | null); const minTileSzRef = ref(null as HTMLInputElement | null); const maxTileSzRef = ref(null as HTMLInputElement | null); const saveIndRef = ref(null as HTMLDivElement | null); -// Global store const store = useStore(); -// Events const emit = defineEmits(['close', 'setting-chg', 'reset']); // For making only two of 'layoutType's values available for user selection) const sweepLeaves = ref(store.lytOpts.layoutType == 'sweep'); watch(sweepLeaves, (newVal) => {store.lytOpts.layoutType = newVal ? 'sweep' : 'rect'}) -// Settings change handling +// ========== Settings change handling ========== + const saved = ref(false); // Set to true after a setting is saved let settingChgTimeout = 0; // Used to throttle some setting-change handling + function onSettingChg(option: string){ // Maintain min/max-tile-size consistency if (option == 'lytOpts.minTileSz' || option == 'lytOpts.maxTileSz'){ @@ -154,8 +158,10 @@ function onSettingChg(option: string){ } } } + // Notify parent (might need to relayout) emit('setting-chg', option); + // Possibly make saved-indicator appear/animate if (!saved.value){ saved.value = true; @@ -166,6 +172,7 @@ function onSettingChg(option: string){ el.classList.add('animate-flash-green'); } } + function onSettingChgThrottled(option: string){ if (settingChgTimeout == 0){ settingChgTimeout = setTimeout(() => { @@ -174,6 +181,7 @@ function onSettingChgThrottled(option: string){ }, store.animationDelay); } } + function onResetOne(option: string){ store.resetOne(option); if (option == 'lytOpts.layoutType'){ @@ -181,24 +189,28 @@ function onResetOne(option: string){ } onSettingChg(option); } + function onReset(){ emit('reset'); // Notify parent (might need to relayout) saved.value = false; // Clear saved-indicator } -// Close handling +// ========== Close handling ========== + function onClose(evt: Event){ if (evt.target == rootRef.value || closeRef.value!.$el.contains(evt.target)){ emit('close'); } } -// Styles and classes +// ========== For styling ========== + const styles = computed(() => ({ backgroundColor: store.color.bgAlt, borderRadius: store.borderRadius + 'px', boxShadow: store.shadowNormal, })); + const borderBClasses = 'border-b border-stone-400'; const rLabelClasses = "w-fit hover:cursor-pointer hover:text-lime-600"; // For reset-upon-click labels -- cgit v1.2.3