Adjust the code format and add the ability to disable the checkbox
This commit is contained in:
parent
ffc3c80378
commit
8683f50bd4
1 changed files with 15 additions and 9 deletions
|
|
@ -1,22 +1,28 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
|
|
||||||
|
const emit = createEventDispatcher();
|
||||||
|
|
||||||
|
export let disabled: boolean = false;
|
||||||
|
export let state: boolean;
|
||||||
export let name: string;
|
export let name: string;
|
||||||
export let id: string;
|
export let id: string;
|
||||||
|
|
||||||
const emit = createEventDispatcher();
|
function onToggle() {
|
||||||
|
emit(`toggle`, id);
|
||||||
let enabled = false;
|
|
||||||
|
|
||||||
function toggleState() {
|
|
||||||
enabled = !enabled;
|
|
||||||
emit(`toggle`, enabled);
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="container">
|
<label class="container" {disabled}>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<input type="checkbox" {name} {id}>
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
{disabled}
|
||||||
|
{name}
|
||||||
|
{id}
|
||||||
|
bind:checked="{state}"
|
||||||
|
on:click="{onToggle}"
|
||||||
|
>
|
||||||
<span class="checkmark"></span>
|
<span class="checkmark"></span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue