Add component for rendering workflow mustache taglines

This commit is contained in:
Andrew Kingston 2020-09-17 17:50:54 +01:00
parent 6c4cf24a94
commit 15cc7a2e6c
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>
import mustache from "mustache"
import { workflowStore, backendUiStore } from "builderStore"
import WorkflowBlockTagline from "./WorkflowBlockTagline.svelte"
export let onSelect
export let block
@ -26,7 +26,6 @@
}
$: inputs = enrichInputs(block.inputs)
$: tagline = block.tagline.replace(/{{/g, "<b>{{").replace(/}}/, "}}</b>")
</script>
<div
@ -41,7 +40,7 @@
<i class="ri-flashlight-fill" />
<span>Do this...</span>
{:else if block.type === 'LOGIC'}
<i class="ri-pause-fill" />
<i class="ri-git-branch-line" />
<span>Only continue if...</span>
{/if}
<div class="label">
@ -50,7 +49,7 @@
</header>
<hr />
<p>
{@html mustache.render(tagline, { inputs })}
<WorkflowBlockTagline tagline={block.tagline} {inputs} />
</p>
</div>
@ -87,7 +86,7 @@
padding: var(--spacing-s);
color: var(--grey-8);
border-radius: var(--border-radius-m);
background-color: var(--grey-2);
background-color: rgba(0, 0, 0, 0.05);
}
header i {
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>