Skip to content

Commit

Permalink
chore: code component
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Dec 9, 2023
1 parent e49fcd9 commit edd6721
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/views/FormBuilder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
<Tabs bind:activeTab={currentTab} tabs={["form", "template"]} />
<div class="body">
{#if currentTab === "template"}
<TemplateEditor formName={definition.name} {fieldNames} />
<div class="template">
<TemplateEditor formName={definition.name} {fieldNames} />
</div>
{:else}
<form on:submit|preventDefault={handleSubmit}>
<fieldset class="flex column gap2 header">
Expand Down Expand Up @@ -430,6 +432,9 @@
overflow: hidden;
}
}
.template {
padding: 1rem;
}
.fields {
overflow-y: auto;
padding: 1rem;
Expand Down
17 changes: 17 additions & 0 deletions src/views/components/Code.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div>
<pre><code><slot /></code></pre>
</div>

<style>
pre {
background-color: var(--background-secondary);
border-radius: var(--border-radius);
padding: 0.5rem;
}
code {
font-family: var(--font-family-monospace);
}
div {
display: flex;
}
</style>
18 changes: 17 additions & 1 deletion src/views/components/TemplateEditor.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts">
import Code from "./Code.svelte";
let templateString = "";
export let formName: string;
export let fieldNames: string[];
Expand All @@ -15,8 +17,12 @@
any text you want and reference the form fields using the <code
>{`{{name}}`}</code
>
syntax. For example: <code>{exampleText}</code>
syntax.
</p>
<div>
<div>For example:</div>
<Code>{exampleText}</Code>
</div>
<div class="fields-list">
Available fields:
<ul>
Expand All @@ -32,3 +38,13 @@
class="form-control"
placeholder="Enter template here"
></textarea>

<style>
.fields-list {
padding-top: 1rem;
}
textarea {
font-family: var(--font-family-monospace);
width: 100%;
}
</style>

0 comments on commit edd6721

Please sign in to comment.