inputs variants in progress

This commit is contained in:
Dmitry Borisenko
2021-09-15 03:17:51 +08:00
parent ba3f94d15f
commit fc1c76fb6b
2 changed files with 39 additions and 18 deletions

View File

@@ -40,8 +40,8 @@
wigets = [ wigets = [
{ {
widget: "input", widget: "input",
status: "30", type: "number",
type: "", status: "30.5",
page: "", page: "",
order: "1", order: "1",
descr: "Boiler temperature", descr: "Boiler temperature",
@@ -49,20 +49,29 @@
}, },
{ {
widget: "input", widget: "input",
status: "31", type: "text",
type: "", status: "Hello",
page: "", page: "",
order: "1", order: "3",
descr: "Room temperature", descr: "Massage to be send",
topic: "/prefix/00000-00003/temp3",
},
{
widget: "input",
type: "date",
status: "2021.09.15",
page: "",
order: "2",
descr: "Switch on boiled date",
topic: "/prefix/00000-00002/temp2", topic: "/prefix/00000-00002/temp2",
}, },
{ {
widget: "input", widget: "input",
status: "32", type: "time",
type: "", status: "12:00",
page: "", page: "",
order: "1", order: "3",
descr: "Body temperature", descr: "Switch on boiler time",
topic: "/prefix/00000-00003/temp3", topic: "/prefix/00000-00003/temp3",
}, },
]; ];
@@ -110,10 +119,10 @@
<Card title="Редактор JSON"> <Card title="Редактор JSON">
<textarea on:input={SuperDuperFunction} rows="10" class="input-indigo" id="text1">{syntaxHighlight(JSON.stringify(wigets))}</textarea> <textarea on:input={SuperDuperFunction} rows="10" class="input-indigo" id="text1">{syntaxHighlight(JSON.stringify(wigets))}</textarea>
</Card> </Card>
<Card title="Dashboard"> <Card title="Inputs">
{#each wigets as widget, i} {#each wigets as widget, i}
{#if widget.widget === "input"} {#if widget.widget === "input"}
<Myinput ws={"ws"} topic={widget.topic} title={widget.descr} bind:value={widget.status} /> <Myinput type={widget.type} ws={1} topic={widget.topic} title={widget.descr} bind:value={widget.status} />
{/if} {/if}
{/each} {/each}
</Card> </Card>

View File

@@ -7,20 +7,32 @@
export let value; export let value;
export let topic; export let topic;
export let ws; export let ws;
export let type;
</script> </script>
<div class="container"> <div class="container">
<div class="block-psn-center-when-md"> <div class="block-psn-center-when-md">
<div class="md:w-2/3"> <div class="md:w-1/2">
<!-- svelte-ignore a11y-label-has-associated-control --> <!-- svelte-ignore a11y-label-has-associated-control -->
<label class="descr-gray-left">{title}</label> <label class="descr-gray-left">{title}</label>
</div> </div>
<div class="md:w-3/3"> <div class="md:w-1/2">
<!-- on:change={WSpush(ws, topic, value)} --> <!-- on:change={WSpush(ws, topic, value)} -->
<input bind:value class="input-indigo" type="text" /> {#if type == "number"}
</div> <input on:change={WSpush(ws, topic, value)} bind:value class="input-indigo" type="number" />
<div class="md:w-3/3"> {/if}
<button on:click={WSpush(ws, topic, value)} class="btn-indigo" type="button">Set</button> {#if type == "text"}
<input on:change={WSpush(ws, topic, value)} bind:value class="input-indigo" type="text" />
{/if}
{#if type == "date"}
<input on:change={WSpush(ws, topic, value)} bind:value class="input-indigo" type="date" />
{/if}
{#if type == "time"}
<input on:change={WSpush(ws, topic, value)} bind:value class="input-indigo" type="time" />
{/if}
</div> </div>
<!-- <div class="md:w-3/3"> -->
<!-- <button on:click={WSpush(ws, topic, value)} class="btn-indigo" type="button">Set</button> -->
<!-- </div> -->
</div> </div>
</div> </div>