Add component for rendering workflow mustache taglines

This commit is contained in:
Andrew Kingston 2020-09-17 17:50:54 +01:00
parent fdf8d2cbab
commit 7458b7757e
3 changed files with 34 additions and 17 deletions

View File

@ -1,12 +0,0 @@
<script>
export let value
$:
</script>
<div>
</div>
<style>
</style>

View File

@ -1,6 +1,6 @@
<script> <script>
import mustache from "mustache"
import { workflowStore, backendUiStore } from "builderStore" import { workflowStore, backendUiStore } from "builderStore"
import WorkflowBlockTagline from "./WorkflowBlockTagline.svelte"
export let onSelect export let onSelect
export let block export let block
@ -26,7 +26,6 @@
} }
$: inputs = enrichInputs(block.inputs) $: inputs = enrichInputs(block.inputs)
$: tagline = block.tagline.replace(/{{/g, "<b>{{").replace(/}}/, "}}</b>")
</script> </script>
<div <div
@ -41,7 +40,7 @@
<i class="ri-flashlight-fill" /> <i class="ri-flashlight-fill" />
<span>Do this...</span> <span>Do this...</span>
{:else if block.type === 'LOGIC'} {:else if block.type === 'LOGIC'}
<i class="ri-pause-fill" /> <i class="ri-git-branch-line" />
<span>Only continue if...</span> <span>Only continue if...</span>
{/if} {/if}
<div class="label"> <div class="label">
@ -50,7 +49,7 @@
</header> </header>
<hr /> <hr />
<p> <p>
{@html mustache.render(tagline, { inputs })} <WorkflowBlockTagline tagline={block.tagline} {inputs} />
</p> </p>
</div> </div>
@ -87,7 +86,7 @@
padding: var(--spacing-s); padding: var(--spacing-s);
color: var(--grey-8); color: var(--grey-8);
border-radius: var(--border-radius-m); border-radius: var(--border-radius-m);
background-color: var(--grey-2); background-color: rgba(0, 0, 0, 0.05);
} }
header i { header i {
font-size: 20px; font-size: 20px;

View File

@ -0,0 +1,30 @@
<script>
import mustache from "mustache"
export let tagline
export let inputs
// Add bolt tags around inputs
$: boldTagline = tagline.replace(/{{/g, "<b>{{").replace(/}}/, "}}</b>")
// Fill in inputs with mustache
$: parsedTagline = mustache.render(boldTagline, { inputs })
// Wrap bound fields inside spans to highlight them
$: html = (parsedTagline || "")
.replace(/{{\s/g, "<span>")
.replace(/\s}}/g, "</span>")
</script>
<div>
{@html html}
</div>
<style>
div :global(span) {
font-size: 0.9em;
background-color: var(--purple-light);
padding: var(--spacing-xs);
border-radius: var(--border-radius-m);
}
</style>