Bind type and value
This commit is contained in:
parent
2540faa0f5
commit
4423bb6775
@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let name: string;
|
export let name: string = "Light Control";
|
||||||
import Form from "./Form.svelte";
|
import Form from "./Form.svelte";
|
||||||
|
|
||||||
function handleOnSubmit() {
|
function handleOnSubmit() {
|
||||||
console.log("Form!");
|
console.log("Submitted");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Colors from "./Colors.svelte";
|
import Colors from "./Colors.svelte";
|
||||||
|
import Input from "./Input.svelte";
|
||||||
|
|
||||||
let url = "/api/setcolor";
|
let url = "/api/setcolor";
|
||||||
let possiblePatterns = [
|
let possiblePatterns = [
|
||||||
@ -89,7 +90,7 @@
|
|||||||
{#if fe.type === "colors"}
|
{#if fe.type === "colors"}
|
||||||
<Colors bind:value={fe.value}/>
|
<Colors bind:value={fe.value}/>
|
||||||
{:else}
|
{: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}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
<button type="submit">Submit</button>
|
<button type="submit">Submit</button>
|
||||||
|
8
web/src/Input.svelte
Normal file
8
web/src/Input.svelte
Normal 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 />
|
Loading…
Reference in New Issue
Block a user