Bind type and value
This commit is contained in:
parent
2540faa0f5
commit
4423bb6775
@ -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>
|
||||
|
||||
|
@ -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
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