update styling of flow items

This commit is contained in:
Peter Clement 2023-10-24 15:17:57 +01:00
parent aad6ab4fb4
commit 7910205807
3 changed files with 92 additions and 72 deletions

View File

@ -5,13 +5,7 @@
import TestDataModal from "./TestDataModal.svelte" import TestDataModal from "./TestDataModal.svelte"
import { flip } from "svelte/animate" import { flip } from "svelte/animate"
import { fly } from "svelte/transition" import { fly } from "svelte/transition"
import { import { Icon, notifications, Modal } from "@budibase/bbui"
Heading,
Icon,
ActionButton,
notifications,
Modal,
} from "@budibase/bbui"
import { ActionStepID } from "constants/backend/automations" import { ActionStepID } from "constants/backend/automations"
import UndoRedoControl from "components/common/UndoRedoControl.svelte" import UndoRedoControl from "components/common/UndoRedoControl.svelte"
import { automationHistoryStore } from "builderStore" import { automationHistoryStore } from "builderStore"
@ -20,7 +14,8 @@
let testDataModal let testDataModal
let confirmDeleteDialog let confirmDeleteDialog
let scrolling = false
let hasScrolled = false
$: blocks = getBlocks(automation) $: blocks = getBlocks(automation)
const getBlocks = automation => { const getBlocks = automation => {
@ -32,58 +27,74 @@
return blocks return blocks
} }
async function deleteAutomation() { const deleteAutomation = async () => {
try { try {
await automationStore.actions.delete($selectedAutomation) await automationStore.actions.delete($selectedAutomation)
} catch (error) { } catch (error) {
notifications.error("Error deleting automation") notifications.error("Error deleting automation")
} }
} }
const handleScroll = e => {
if (e.target.scrollTop >= 30 && !hasScrolled) {
scrolling = true
hasScrolled = true
} else if (e.target.scrollTop < 30 && hasScrolled) {
// Set scrolling back to false if scrolled back to less than 100px
scrolling = false
hasScrolled = false
}
}
</script> </script>
<div class="canvas"> <div class="header" class:scrolling>
<div class="header"> <div class="header-left">
<Heading size="S">{automation.name}</Heading> <UndoRedoControl store={automationHistoryStore} />
<div class="controls"> </div>
<UndoRedoControl store={automationHistoryStore} /> <div class="controls">
<div class="buttons">
<Icon hoverable size="M" name="Play" />
<div
on:click={() => {
testDataModal.show()
}}
>
Run test
</div>
</div>
<div class="buttons">
<Icon <Icon
on:click={confirmDeleteDialog.show} disabled={!$automationStore.testResults}
hoverable hoverable
size="M" size="M"
name="DeleteOutline" name="Multiple"
/> />
<div class="buttons"> <div
<ActionButton class:disabled={!$automationStore.testResults}
on:click={() => { on:click={() => {
testDataModal.show() $automationStore.showTestPanel = true
}} }}
icon="MultipleCheck" >
size="M">Run test</ActionButton Test details
>
<ActionButton
disabled={!$automationStore.testResults}
on:click={() => {
$automationStore.showTestPanel = true
}}
size="M">Test Details</ActionButton
>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="content"> <div class="canvas" on:scroll={handleScroll}>
{#each blocks as block, idx (block.id)} <div class="content">
<div {#each blocks as block, idx (block.id)}
class="block" <div
animate:flip={{ duration: 500 }} class="block"
in:fly={{ x: 500, duration: 500 }} animate:flip={{ duration: 500 }}
out:fly|local={{ x: 500, duration: 500 }} in:fly={{ x: 500, duration: 500 }}
> out:fly|local={{ x: 500, duration: 500 }}
{#if block.stepId !== ActionStepID.LOOP} >
<FlowItem {testDataModal} {block} {idx} /> {#if block.stepId !== ActionStepID.LOOP}
{/if} <FlowItem {testDataModal} {block} {idx} />
</div> {/if}
{/each} </div>
{/each}
</div>
</div> </div>
<ConfirmDialog <ConfirmDialog
bind:this={confirmDeleteDialog} bind:this={confirmDeleteDialog}
@ -103,6 +114,12 @@
<style> <style>
.canvas { .canvas {
padding: var(--spacing-l) var(--spacing-xl); padding: var(--spacing-l) var(--spacing-xl);
overflow-y: auto;
max-height: 100%;
}
.header-left :global(div) {
border-right: none;
} }
/* Fix for firefox not respecting bottom padding in scrolling containers */ /* Fix for firefox not respecting bottom padding in scrolling containers */
.canvas > *:last-child { .canvas > *:last-child {
@ -117,23 +134,45 @@
} }
.content { .content {
display: inline-block; flex-grow: 1;
text-align: left; padding: 23px 23px 80px;
box-sizing: border-box;
}
.header.scrolling {
background: var(--background);
z-index: -1;
border-bottom: var(--border-light);
background: var(--background);
} }
.header { .header {
z-index: 1;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding-left: var(--spacing-l);
transition: background 130ms ease-out;
flex: 0 0 48px;
padding-right: var(--spacing-xl);
}
.controls {
display: flex;
gap: var(--spacing-xl);
} }
.controls,
.buttons { .buttons {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
gap: var(--spacing-xl);
}
.buttons {
gap: var(--spacing-s); gap: var(--spacing-s);
} }
.buttons:hover {
cursor: pointer;
}
.disabled {
pointer-events: none;
color: var(--spectrum-global-color-gray-500) !important;
}
</style> </style>

View File

@ -16,11 +16,7 @@
import ActionModal from "./ActionModal.svelte" import ActionModal from "./ActionModal.svelte"
import FlowItemHeader from "./FlowItemHeader.svelte" import FlowItemHeader from "./FlowItemHeader.svelte"
import RoleSelect from "components/design/settings/controls/RoleSelect.svelte" import RoleSelect from "components/design/settings/controls/RoleSelect.svelte"
import { import { ActionStepID, TriggerStepID } from "constants/backend/automations"
ActionStepID,
TriggerStepID,
Features,
} from "constants/backend/automations"
import { permissions } from "stores/backend" import { permissions } from "stores/backend"
export let block export let block
@ -172,28 +168,14 @@
{block} {block}
{testDataModal} {testDataModal}
{idx} {idx}
{addLooping}
{deleteStep}
on:toggle={() => (open = !open)} on:toggle={() => (open = !open)}
/> />
{#if open} {#if open}
<Divider noMargin /> <Divider noMargin />
<div class="blockSection"> <div class="blockSection">
<Layout noPadding gap="S"> <Layout noPadding gap="S">
{#if !isTrigger}
<div>
<div class="block-options">
{#if !loopBlock && (block?.features?.[Features.LOOPING] || !block.features)}
<ActionButton on:click={() => addLooping()} icon="Reuse">
Add Looping
</ActionButton>
{/if}
<ActionButton
on:click={() => deleteStep()}
icon="DeleteOutline"
/>
</div>
</div>
{/if}
{#if isAppAction} {#if isAppAction}
<Label>Role</Label> <Label>Role</Label>
<RoleSelect bind:value={role} /> <RoleSelect bind:value={role} />

View File

@ -91,7 +91,6 @@
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: flex-start;
align-items: stretch; align-items: stretch;
gap: var(--spacing-l);
overflow: auto; overflow: auto;
} }
.centered { .centered {