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">
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
const emit = createEventDispatcher();
|
||||
|
||||
export let disabled: boolean = false;
|
||||
export let state: boolean;
|
||||
export let name: string;
|
||||
export let id: string;
|
||||
|
||||
const emit = createEventDispatcher();
|
||||
|
||||
let enabled = false;
|
||||
|
||||
function toggleState() {
|
||||
enabled = !enabled;
|
||||
emit(`toggle`, enabled);
|
||||
function onToggle() {
|
||||
emit(`toggle`, id);
|
||||
};
|
||||
</script>
|
||||
|
||||
<label class="container">
|
||||
<label class="container" {disabled}>
|
||||
<slot></slot>
|
||||
<input type="checkbox" {name} {id}>
|
||||
<input
|
||||
type="checkbox"
|
||||
{disabled}
|
||||
{name}
|
||||
{id}
|
||||
bind:checked="{state}"
|
||||
on:click="{onToggle}"
|
||||
>
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue