Bind type and value

This commit is contained in:
Austen Adler 2021-08-15 21:16:39 -04:00
parent 2540faa0f5
commit 4423bb6775
3 changed files with 12 additions and 3 deletions

View File

@ -1,9 +1,9 @@
<script lang="ts">
export let name: string;
export let name: string = "Light Control";
import Form from "./Form.svelte";
function handleOnSubmit() {
console.log("Form!");
console.log("Submitted");
}
</script>

View File

@ -1,5 +1,6 @@
<script lang="ts">
import Colors from "./Colors.svelte";
import Input from "./Input.svelte";
let url = "/api/setcolor";
let possiblePatterns = [
@ -89,7 +90,7 @@
{#if fe.type === "colors"}
<Colors bind:value={fe.value}/>
{:else}
<input type={fe.type} name={fe.name} on:input={(e) => fe.value = e.target.value} />
<Input bind:value={fe.value} type={fe.type} />
{/if}
{/each}
<button type="submit">Submit</button>

8
web/src/Input.svelte Normal file
View File

@ -0,0 +1,8 @@
<script lang="ts">
export let type;
export let value;
const setType = (node) => {
node.type = type;
};
</script>
<input use:setType bind:value />