Files
IoTManagerWeb/src/widgets/Input.svelte

26 lines
1.5 KiB
Svelte
Raw Normal View History

2021-09-16 02:00:52 +08:00
<script>
2021-10-16 21:27:57 +08:00
export let widget;
export let wsPush = (ws, topic, status) => {};
2021-09-16 02:00:52 +08:00
</script>
2021-12-28 23:55:14 +01:00
<div class="crd-itm-psn">
2022-02-11 00:22:41 +01:00
<div class="w-2/3">
2021-09-17 23:18:06 +08:00
<!-- svelte-ignore a11y-label-has-associated-control -->
2021-12-28 23:55:14 +01:00
<label class="wgt-dscr-stl">{!widget.descr ? "" : widget.descr}</label>
2021-09-17 23:18:06 +08:00
</div>
2022-02-11 00:22:41 +01:00
<div class="flex justify-end w-1/3">
2021-10-16 21:27:57 +08:00
{#if widget.type == "number"}
<input class={widget.sent ? "ipt-rnd text-right border-red-500" : "ipt-rnd text-right focus:border-indigo-500"} on:change={() => ((widget.sent = true), wsPush(widget.ws, widget.topic, widget.status))} bind:value={widget.status} step="0.01" type="number" />
2021-09-17 23:18:06 +08:00
{/if}
2021-10-16 21:27:57 +08:00
{#if widget.type == "text"}
<input class={widget.sent ? "ipt-rnd text-right border-red-500" : "ipt-rnd text-right focus:border-indigo-500"} on:change={() => ((widget.sent = true), wsPush(widget.ws, widget.topic, widget.status))} bind:value={widget.status} type="text" />
2021-09-17 23:18:06 +08:00
{/if}
2021-10-16 21:27:57 +08:00
{#if widget.type == "date"}
<input class={widget.sent ? "ipt-rnd text-right border-red-500" : "ipt-rnd text-right focus:border-indigo-500"} on:change={() => ((widget.sent = true), wsPush(widget.ws, widget.topic, widget.status))} bind:value={widget.status} type="date" />
2021-09-17 23:18:06 +08:00
{/if}
2021-10-16 21:27:57 +08:00
{#if widget.type == "time"}
<input class={widget.sent ? "ipt-rnd text-right border-red-500" : "ipt-rnd text-right focus:border-indigo-500"} on:change={() => ((widget.sent = true), wsPush(widget.ws, widget.topic, widget.status))} bind:value={widget.status} type="time" />
2021-09-17 23:18:06 +08:00
{/if}
2021-09-16 02:00:52 +08:00
</div>
</div>