From 6a4f47a4c8edd3e45c935c2c52be626684ad0c54 Mon Sep 17 00:00:00 2001 From: Joe <49767913+joebudi@users.noreply.github.com> Date: Wed, 1 Jul 2020 14:46:22 +0100 Subject: [PATCH] formatting and lint --- .../Colorpicker/Colorpicker.svelte | 8 +- .../Colorpicker/Colorpreview.svelte | 39 +++--- .../userInterface/Colorpicker/Portal.svelte | 30 ++--- .../ComponentPropertiesPanel.svelte | 4 +- .../userInterface/DesignView.svelte | 6 +- .../userInterface/OptionSelect.svelte | 102 +++++++-------- .../userInterface/PropertyGroup.svelte | 2 +- .../userInterface/temporaryPanelStructure.js | 4 +- .../src/pages/[application]/_reset.svelte | 4 +- .../model/[selectedModel]/_layout.svelte | 17 +-- .../backend/model/_layout.svelte | 6 +- .../[application]/backend/model/index.svelte | 14 +- .../standard-components/src/DataTable.svelte | 121 +++++++++--------- 13 files changed, 182 insertions(+), 175 deletions(-) diff --git a/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte b/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte index 27b5e20b5b..eed0e74e29 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte @@ -16,7 +16,7 @@ import Portal from "./Portal.svelte" export let value = "#3ec1d3ff" - export let open = false; + export let open = false export let swatches = [] //TODO: Safe swatches - limit to 12. warn in console export let disableSwatches = false export let format = "hexa" @@ -40,7 +40,7 @@ getRecentColors() } - if(colorPicker) { + if (colorPicker) { colorPicker.focus() } @@ -57,7 +57,7 @@ } function handleEscape(e) { - if(open && e.key === "Escape") { + if (open && e.key === "Escape") { open = false } } @@ -159,10 +159,8 @@ $: border = v > 90 && s < 5 ? "1px dashed #dedada" : "" $: selectedColorStyle = buildStyle({ background: value, border }) $: shrink = swatches.length > 0 - -
spaceBelow) { + if (spaceAbove > spaceBelow) { positionSide = "bottom" - y = (window.innerHeight - spaceAbove) - }else{ + y = window.innerHeight - spaceAbove + } else { positionSide = "top" y = bottom } - x = (left + previewCenter) - (pickerWidth / 2) + x = left + previewCenter - pickerWidth / 2 dimensions = { [positionSide]: y.toFixed(1), left: x.toFixed(1) } } @@ -83,7 +82,6 @@ [positionSide]: `${dimensions[positionSide]}px`, left: `${dimensions.left}px`, }) -
@@ -99,19 +97,18 @@ {#if open} - +
(open = false)} class="overlay" /> {/if} {:else} diff --git a/packages/builder/src/components/userInterface/Colorpicker/Portal.svelte b/packages/builder/src/components/userInterface/Colorpicker/Portal.svelte index 9af289175a..462a176e4f 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/Portal.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/Portal.svelte @@ -1,35 +1,35 @@
diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 60e758b0b6..eb5dc682aa 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -99,9 +99,7 @@ {selectedCategory} /> {#if displayName} -
- {componentInstance._instanceName} -
+
{componentInstance._instanceName}
{/if}
diff --git a/packages/builder/src/components/userInterface/DesignView.svelte b/packages/builder/src/components/userInterface/DesignView.svelte index 408dc54d06..9db0001266 100644 --- a/packages/builder/src/components/userInterface/DesignView.svelte +++ b/packages/builder/src/components/userInterface/DesignView.svelte @@ -1,9 +1,8 @@
@@ -55,7 +53,7 @@ {componentDefinition} {componentInstance} open={currentGroup === groupName} - on:open={() => currentGroup = groupName} /> + on:open={() => (currentGroup = groupName)} /> {/each} {:else}
diff --git a/packages/builder/src/components/userInterface/OptionSelect.svelte b/packages/builder/src/components/userInterface/OptionSelect.svelte index 26f061cb58..10323a1d20 100644 --- a/packages/builder/src/components/userInterface/OptionSelect.svelte +++ b/packages/builder/src/components/userInterface/OptionSelect.svelte @@ -13,13 +13,13 @@ let selectMenu let icon - let selectAnchor = null; - let dimensions = {top: 0, bottom: 0, left: 0} + let selectAnchor = null + let dimensions = { top: 0, bottom: 0, left: 0 } let positionSide = "top" let maxHeight = 0 - let scrollTop = 0; - let containerEl = null; + let scrollTop = 0 + let containerEl = null const handleStyleBind = value => !!styleBindingProperty ? { style: `${styleBindingProperty}: ${value}` } : {} @@ -32,51 +32,53 @@ return () => { select.removeEventListener("keydown", handleEnter) } - }) function handleEscape(e) { - if(open && e.key === "Escape") { - toggleSelect(false) + if (open && e.key === "Escape") { + toggleSelect(false) } } function getDimensions() { - const { bottom, top: spaceAbove, left } = selectAnchor.getBoundingClientRect() + const { + bottom, + top: spaceAbove, + left, + } = selectAnchor.getBoundingClientRect() const spaceBelow = window.innerHeight - bottom - let y; + let y if (spaceAbove > spaceBelow) { positionSide = "bottom" - maxHeight = spaceAbove - 20 - y = (window.innerHeight - spaceAbove) + maxHeight = spaceAbove - 20 + y = window.innerHeight - spaceAbove } else { positionSide = "top" y = bottom maxHeight = spaceBelow - 20 } - dimensions = {[positionSide]: y, left} + dimensions = { [positionSide]: y, left } } function handleEnter(e) { if (!open && e.key === "Enter") { - toggleSelect(true) - } + toggleSelect(true) + } } function toggleSelect(isOpen) { getDimensions() if (isOpen) { - icon.style.transform = "rotate(180deg)" + icon.style.transform = "rotate(180deg)" } else { icon.style.transform = "rotate(0deg)" } open = isOpen } - function handleClick(val) { value = val onChange(value) @@ -86,7 +88,7 @@ "max-height": `${maxHeight.toFixed(0)}px`, "transform-origin": `center ${positionSide}`, [positionSide]: `${dimensions[positionSide]}px`, - "left": `${dimensions.left.toFixed(0)}px`, + left: `${dimensions.left.toFixed(0)}px`, }) $: isOptionsObject = options.every(o => typeof o === "object") @@ -95,7 +97,7 @@ ? options.find(o => o.value === value) : {} - $: if(open && selectMenu) { + $: if (open && selectMenu) { selectMenu.focus() } @@ -113,38 +115,38 @@
{#if open} - -
-
    - {#if isOptionsObject} - {#each options as { value: v, label }} -
  • - {label} -
  • - {/each} - {:else} - {#each options as v} -
  • - {v} -
  • - {/each} - {/if} -
-
-
toggleSelect(false)} class="overlay" /> - + +
+
    + {#if isOptionsObject} + {#each options as { value: v, label }} +
  • + {label} +
  • + {/each} + {:else} + {#each options as v} +
  • + {v} +
  • + {/each} + {/if} +
+
+
toggleSelect(false)} class="overlay" /> + {/if}
diff --git a/packages/builder/src/components/userInterface/PropertyGroup.svelte b/packages/builder/src/components/userInterface/PropertyGroup.svelte index 511807b2e6..0da68c51d0 100644 --- a/packages/builder/src/components/userInterface/PropertyGroup.svelte +++ b/packages/builder/src/components/userInterface/PropertyGroup.svelte @@ -13,7 +13,7 @@ $: style = componentInstance["_styles"][styleCategory] || {} - + {#each properties as props} { if (!state.previousTopNavPath) state.previousTopNavPath = {} - state.previousTopNavPath[activeTopNav.path] = window.location.pathname.replace("/_builder", "") + state.previousTopNavPath[ + activeTopNav.path + ] = window.location.pathname.replace("/_builder", "") $goto(state.previousTopNavPath[path] || path) return state }) diff --git a/packages/builder/src/pages/[application]/backend/model/[selectedModel]/_layout.svelte b/packages/builder/src/pages/[application]/backend/model/[selectedModel]/_layout.svelte index a3ce7c6bf9..4ed98f3a38 100644 --- a/packages/builder/src/pages/[application]/backend/model/[selectedModel]/_layout.svelte +++ b/packages/builder/src/pages/[application]/backend/model/[selectedModel]/_layout.svelte @@ -1,14 +1,15 @@ diff --git a/packages/builder/src/pages/[application]/backend/model/_layout.svelte b/packages/builder/src/pages/[application]/backend/model/_layout.svelte index ee17644f3a..d9a69b4250 100644 --- a/packages/builder/src/pages/[application]/backend/model/_layout.svelte +++ b/packages/builder/src/pages/[application]/backend/model/_layout.svelte @@ -10,7 +10,11 @@ onMount(async () => { // navigate to first model in list, if not already selected // and this is the final url (i.e. no selectedModel) - if (!$leftover && $backendUiStore.models.length > 0 && (!$backendUiStore.selectedModel || !$backendUiStore.selectedModel._id)) { + if ( + !$leftover && + $backendUiStore.models.length > 0 && + (!$backendUiStore.selectedModel || !$backendUiStore.selectedModel._id) + ) { $goto(`./${$backendUiStore.models[0]._id}`) } }) diff --git a/packages/builder/src/pages/[application]/backend/model/index.svelte b/packages/builder/src/pages/[application]/backend/model/index.svelte index 15a08b1d09..f72878a871 100644 --- a/packages/builder/src/pages/[application]/backend/model/index.svelte +++ b/packages/builder/src/pages/[application]/backend/model/index.svelte @@ -8,9 +8,13 @@ } onMount(async () => { - // navigate to first model in list, if not already selected + // navigate to first model in list, if not already selected // and this is the final url (i.e. no selectedModel) - if (!$leftover && $backendUiStore.models.length > 0 && (!$backendUiStore.selectedModel || !$backendUiStore.selectedModel._id)) { + if ( + !$leftover && + $backendUiStore.models.length > 0 && + (!$backendUiStore.selectedModel || !$backendUiStore.selectedModel._id) + ) { // this file routes as .../models/index, so, go up one. $goto(`../${$backendUiStore.models[0]._id}`) } @@ -18,7 +22,5 @@ {#if $backendUiStore.models.length === 0} -Please create a model -{:else} -Please select a model -{/if} + Please create a model +{:else}Please select a model{/if} diff --git a/packages/standard-components/src/DataTable.svelte b/packages/standard-components/src/DataTable.svelte index 94886b8d29..18953f6292 100644 --- a/packages/standard-components/src/DataTable.svelte +++ b/packages/standard-components/src/DataTable.svelte @@ -68,71 +68,76 @@