MapComplete/src/UI/Base/Checkbox.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
522 B
Svelte
Raw Normal View History

2023-03-28 05:13:48 +02:00
<script lang="ts">
2023-12-13 01:01:56 +01:00
import { UIEventSource } from "../../Logic/UIEventSource"
2023-03-28 05:13:48 +02:00
/**
* For some stupid reason, it is very hard to bind inputs
*/
2023-12-13 01:01:56 +01:00
export let selected: UIEventSource<boolean>
2023-09-28 23:50:27 +02:00
let _c: boolean = selected.data ?? true
2024-04-13 02:40:21 +02:00
let id = `checkbox-input-${Math.round(Math.random() * 100000000)}`
2023-09-28 23:50:27 +02:00
$: selected.set(_c)
2024-04-13 02:40:21 +02:00
selected.addCallbackD((s) => {
_c = s
})
2023-03-28 05:13:48 +02:00
</script>
2023-09-28 23:50:27 +02:00
2023-12-13 01:01:56 +01:00
<label class="no-image-background flex items-center gap-1">
2024-02-20 23:22:13 +01:00
<input bind:checked={_c} type="checkbox" {id} />
<slot />
</label>