Add labels to workflow blocks

This commit is contained in:
Andrew Kingston 2020-09-17 15:07:32 +01:00
parent 1cba3f2f8e
commit f341b5f0a9
1 changed files with 35 additions and 15 deletions

View File

@ -6,9 +6,9 @@
export let block export let block
let selected let selected
$: selected = $: selected = $workflowStore.selectedBlock?.id === block.id
$workflowStore.selectedBlock != null && $: steps = $workflowStore.selectedWorkflow?.workflow?.definition?.steps ?? []
$workflowStore.selectedBlock.id === block.id $: blockIdx = steps.findIndex(step => step.id === block.id)
function selectBlock() { function selectBlock() {
onSelect(block) onSelect(block)
@ -31,18 +31,24 @@
.replaceAll("}}", "}}</b>") .replaceAll("}}", "}}</b>")
</script> </script>
<div class={`${block.type} hoverable`} class:selected on:click={selectBlock}> <div
class={`block ${block.type} hoverable`}
class:selected
on:click={selectBlock}>
<header> <header>
{#if block.type === 'TRIGGER'} {#if block.type === 'TRIGGER'}
<i class="ri-lightbulb-fill" /> <i class="ri-lightbulb-fill" />
When this happens... <span>When this happens...</span>
{:else if block.type === 'ACTION'} {:else if block.type === 'ACTION'}
<i class="ri-flashlight-fill" /> <i class="ri-flashlight-fill" />
Do this... <span>Do this...</span>
{:else if block.type === 'LOGIC'} {:else if block.type === 'LOGIC'}
<i class="ri-pause-fill" /> <i class="ri-pause-fill" />
Only continue if... <span>Only continue if...</span>
{/if} {/if}
<div class="label">
{#if block.type === 'TRIGGER'}Trigger{:else}Step {blockIdx + 1}{/if}
</div>
</header> </header>
<hr /> <hr />
<p> <p>
@ -51,7 +57,7 @@
</div> </div>
<style> <style>
div { .block {
width: 320px; width: 320px;
padding: 20px; padding: 20px;
border-radius: var(--border-radius-m); border-radius: var(--border-radius-m);
@ -61,14 +67,30 @@
font-size: 16px; font-size: 16px;
color: var(--white); color: var(--white);
} }
.block.selected,
.block:hover {
transform: scale(1.1);
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.15);
}
header { header {
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
display: flex; display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center; align-items: center;
} }
header span {
flex: 1 1 auto;
}
header .label {
font-size: 14px;
padding: var(--spacing-s);
color: var(--grey-8);
border-radius: var(--border-radius-m);
background-color: var(--grey-2);
}
header i { header i {
font-size: 20px; font-size: 20px;
margin-right: 5px; margin-right: 5px;
@ -83,6 +105,10 @@
background-color: var(--ink); background-color: var(--ink);
color: var(--white); color: var(--white);
} }
.TRIGGER header .label {
background-color: var(--grey-9);
color: var(--grey-5);
}
.LOGIC { .LOGIC {
background-color: var(--blue-light); background-color: var(--blue-light);
@ -93,10 +119,4 @@
color: inherit; color: inherit;
margin-bottom: 0; margin-bottom: 0;
} }
div.selected,
div:hover {
transform: scale(1.1);
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.15);
}
</style> </style>