fix: multiple UI fixes

This commit is contained in:
Ruben Fiszel
2022-07-26 17:28:36 +02:00
parent 326a97a96e
commit 767c0a9acf
9 changed files with 65 additions and 50 deletions
+2 -4
View File
@@ -184,7 +184,7 @@
{error === '' ? '...' : error}
</div>
</div>
<div class="container">
<div class="flex flex-row gap-1">
{#if inputCat == 'number' && !numberAsString}
<input
{disabled}
@@ -279,6 +279,7 @@
/>
{:else if inputCat == 'string' || (inputCat == 'number' && numberAsString)}
<textarea
on:focus={() => dispatch('focus')}
{disabled}
style="height: {minHeight}; max-height: {maxHeight}"
class="col-span-10 {valid
@@ -302,6 +303,3 @@
</div>
</div>
</div>
<style>
</style>
@@ -36,8 +36,6 @@
let open = 0
let args: Record<string, any> = {}
$: numberOfSteps = $flowStore?.value.modules.length - 1
</script>
<Modal bind:this={jsonSetter}>
@@ -197,7 +195,12 @@
<div class="p-4">
<SchemaEditor schema={$flowStore.schema} />
<div class="my-4" />
<FlowPreview {mode} flow={$flowStore} i={numberOfSteps} bind:args />
<FlowPreview
{mode}
flow={$flowStore}
i={$flowStore?.value.modules.length}
bind:args
/>
</div>
</div>
</li>
+11 -11
View File
@@ -28,7 +28,7 @@
let intervalId: NodeJS.Timer
let uptoText =
i == flow.value.modules.length - 1 ? 'Preview whole flow' : 'Preview up to this step'
i >= flow.value.modules.length - 1 ? 'Preview whole flow' : 'Preview up to this step'
let job: Job | undefined
let jobs = []
let jobId: string
@@ -89,21 +89,21 @@
})
</script>
<h2 class="flex justify-center">
<button
class="default-button "
on:click={() => {
viewPreview = !viewPreview
}}
>
<button
class="w-full bg-blue-200"
on:click={() => {
viewPreview = !viewPreview
}}
>
<h2 class="flex justify-center">
<div>
Preview mode<Icon class="ml-1" data={viewPreview ? faChevronUp : faChevronDown} scale={1} />
</div>
</button>
</h2>
</h2>
</button>
{#if viewPreview}
{#if i != flow.value.modules.length - 1}
{#if i != flow.value.modules.length}
<Tabs
tabs={[
['upto', uptoText],
@@ -2,7 +2,7 @@
import { FlowModuleValue, type FlowModule } from '$lib/gen'
import { previewResults } from '$lib/stores'
import { buildExtraLib, objectToTsType, schemaToTsType } from '$lib/utils'
import { faRobot } from '@fortawesome/free-solid-svg-icons'
import { faChevronDown, faChevronUp, faRobot } from '@fortawesome/free-solid-svg-icons'
import Icon from 'svelte-awesome'
import Editor from './Editor.svelte'
import EditorBar from './EditorBar.svelte'
@@ -143,11 +143,15 @@
{/if}
{#if open == i}
<div>
<button class="w-full h-full" on:click={() => (open = -1)}>(-)</button>
<button class="w-full h-full" on:click={() => (open = -1)}
><Icon data={faChevronUp} scale={1.0} /></button
>
</div>
{:else}
<div>
<button class="w-full h-full" on:click={() => (open = i)}>(+)</button>
<button class="w-full h-full" on:click={() => (open = i)}
><Icon data={faChevronDown} scale={1.0} /></button
>
</div>
{/if}
</div>
+1 -1
View File
@@ -66,7 +66,7 @@
</h2>
{/if}
{#if !runnable.schema.properties || Object.keys(runnable.schema.properties).length === 0}
<div class="text-sm">No arguments</div>
<div class="text-sm p-6">No arguments</div>
{:else}
<div
class="bg-gray-50 border border shadow-md shadow-blue-100 shadow-inner rounded border-gray-300 p-6"
@@ -21,6 +21,7 @@
export let pickableProperties: Object | undefined = undefined
let inputCheck: { [id: string]: boolean } = {}
let overlays: { [id: string]: OverlayPropertyPicker } = {}
$: isValid = allTrue(inputCheck) ?? false
let propertiesTypes: { [id: string]: InputTransform.type } = {}
@@ -103,6 +104,7 @@
{#if propertiesTypes[argName] === undefined || propertiesTypes[argName] === InputTransform.type.STATIC}
<OverlayPropertyPicker
bind:this={overlays[argName]}
bind:pickableProperties
disabled={!hasOverlay(inputCats[argName])}
on:select={(event) => {
@@ -112,6 +114,15 @@
}}
>
<ArgInput
on:focus={() => {
Object.keys(overlays).forEach((k) => {
if (k == argName) {
overlays[k].focus()
} else {
overlays[k].unfocus()
}
})
}}
label={argName}
bind:description={schema.properties[argName].description}
bind:value={args[argName].value}
@@ -102,9 +102,6 @@
@apply text-black;
}
.hidden {
display: none;
}
.val {
@apply text-black;
}
@@ -11,38 +11,40 @@
export let pickableProperties: Object | undefined
export let disabled = false
let isOpen = false
let isFocused = true
let timeout: NodeJS.Timeout
export function unfocus() {
isFocused = false
close()
}
export function focus() {
isFocused = true
open()
}
function open() {
if (isFocused) {
clearTimeout(timeout)
!isOpen && (isOpen = true)
}
}
function close() {
timeout = setTimeout(() => (isOpen = false), 200)
}
const dispatch = createEventDispatcher()
function toggle() {
isOpen = !isOpen
}
function onMouseLeave(mouseEvent: MouseEvent) {
const { offsetY } = mouseEvent
const target = mouseEvent.target as HTMLInputElement
const down = offsetY >= target.clientHeight
const up = offsetY <= 0
const content = document.getElementsByClassName('content')
const overlayBottom = content.item(0)?.getAttribute('data-popper-placement') === 'bottom'
if ((down && overlayBottom) || (up && !overlayBottom)) {
return
}
toggle()
}
</script>
{#if !disabled}
<div class="w-full">
<div use:popperRef on:mousemove={() => !isOpen && toggle()} on:mouseleave={onMouseLeave}>
<div use:popperRef on:mouseenter={open} on:mouseleave={close}>
<slot />
</div>
{#if isOpen}
<div class="content" use:popperContent on:mouseleave={toggle}>
<div class="content" use:popperContent on:mouseenter={open} on:mouseleave={close}>
<PropPicker
bind:pickableProperties
on:select={(event) => {
@@ -11,14 +11,14 @@
search === EMPTY_STRING ? pickableProperties : keepByKey(pickableProperties, search)
</script>
<!-- {JSON.stringify(propsFiltered)} -->
<div
class="relative p-3 bg-white rounded-lg border border-gray-200 shadow-md max-h-max overflow-y-scroll w-full"
class="relative p-3 bg-white rounded-lg border border-gray-200 shadow-md max-h-max overflow-y-scroll"
>
<div class="overflow-y-auto max-h-96">
<input
type="text"
bind:value={search}
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg block w-full p-2 mb-2"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg block p-2 mb-2"
placeholder="Search prop..."
/>
<ObjectViewer json={propsFiltered} on:select />