Skip to content

Commit

Permalink
chore: nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Dec 24, 2023
1 parent ec1d44b commit 0347765
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/std/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const E = {
ap,
flap,
chainW,
fold: match,
};

export const O = {
Expand Down
6 changes: 6 additions & 0 deletions src/views/FormBuilder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ParsedTemplate,
parsedTemplateToString,
} from "src/core/template/templateParser";
import InputBuilderDocumentBlock from "./components/InputBuilderDocumentBlock.svelte";
export let definition: EditableFormDefinition = {
title: "",
Expand Down Expand Up @@ -370,6 +371,11 @@
{index}
bind:value={field.input.query}
/>
{:else if field.input.type === "document_block"}
<InputBuilderDocumentBlock
{index}
bind:body={field.input.body}
/>
{/if}
</div>
<div class="flex gap1">
Expand Down
20 changes: 17 additions & 3 deletions src/views/components/InputBuilderDocumentBlock.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<script lang="ts">
import { E, pipe, parseFunctionBody } from "@std";
import FormRow from "./FormRow.svelte";
let text = "";
const id = "document_block";
export let body = "";
export let index: number;
$: id = "document_block_" + index;
const placeholder = "return `Hello ${form.name}!`";
$: errors = pipe(
parseFunctionBody(body),
E.fold(
(e) => e.message,
() => "",
),
);
$: console.log(errors);
</script>

<FormRow label="Document block" {id}>
Expand All @@ -15,11 +25,15 @@
variable. For example:
<pre class="language-js">{placeholder}</pre>
<textarea
bind:value={text}
bind:value={body}
name="document_block"
class="form-control"
rows="3"
{placeholder}
/>
{#if errors}
Your function body has errors:
<div class="modal-form-error-message">{errors}</div>
{/if}
</span></FormRow
>
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ If your plugin does not need CSS, delete this file.
.notice-error {
color: var(--text-error);
}
.modal-form-error-message {
color: var(--text-error);
font-weight: bold;
}

0 comments on commit 0347765

Please sign in to comment.