Files
IoTManagerWeb/src/widgets/Toggle.svelte

24 lines
911 B
Svelte
Raw Normal View History

2021-10-19 21:59:48 +08:00
<script context="module">
import { WSpush } from "../App.svelte";
</script>
<script>
export let widget;
</script>
2021-10-20 20:53:07 +08:00
<div class="card-items-psn-inline">
2021-10-25 20:05:21 +07:00
<div class="widget-descr-width-inline">
2021-10-19 21:59:48 +08:00
<!-- svelte-ignore a11y-label-has-associated-control -->
2021-10-20 20:53:07 +08:00
<label class="widget-descr-style">{!widget.descr ? "" : widget.descr}</label>
2021-10-19 21:59:48 +08:00
</div>
2021-10-25 20:05:21 +07:00
<div class="widget-width-inline">
2021-10-25 16:50:31 +07:00
<label for={widget.topic} class="items-center cursor-pointer">
<div class="relative">
<input on:change={() => ((widget["send"] = true), WSpush(widget.ws, widget.topic, widget.status))} bind:value={widget.status} id={widget.topic} type="checkbox" class="sr-only" />
2021-10-27 05:11:28 +07:00
<div class="block bg-gray-600 w-10 h-6 rounded-full" />
<div class="dot {widget['send'] == true ? 'bg-red-400' : 'bg-white'} absolute left-1 top-1 w-4 h-4 rounded-full transition" />
2021-10-25 16:50:31 +07:00
</div>
</label>
2021-10-19 21:59:48 +08:00
</div>
</div>