2022-03-03 00:42:43 +08:00
|
|
|
<script lang="ts">
|
|
|
|
import { createEventDispatcher } from "svelte";
|
2022-03-12 00:00:48 +08:00
|
|
|
|
2022-04-06 01:11:29 +08:00
|
|
|
import { BlockTitle, Block } from "@gradio/atoms";
|
|
|
|
|
2022-03-03 00:42:43 +08:00
|
|
|
export let value: boolean;
|
2022-03-12 00:00:48 +08:00
|
|
|
export let disabled: boolean = false;
|
2022-04-06 01:11:29 +08:00
|
|
|
export let label: string;
|
2022-04-09 02:46:00 +08:00
|
|
|
export let style: string = "";
|
2022-04-22 17:19:59 +08:00
|
|
|
export let form_position: "first" | "last" | "mid" | "single" = "single";
|
2022-03-03 00:42:43 +08:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher<{ change: boolean }>();
|
|
|
|
|
|
|
|
function handle_change() {
|
|
|
|
dispatch("change", !value);
|
|
|
|
value = !value;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-04-22 17:19:59 +08:00
|
|
|
<Block {form_position}>
|
2022-04-06 01:11:29 +08:00
|
|
|
<!-- svelte-ignore a11y-label-has-associated-control -->
|
2022-04-21 17:27:12 +08:00
|
|
|
<label
|
|
|
|
class:!cursor-not-allowed={disabled}
|
|
|
|
class="flex items-center text-gray-700 text-sm space-x-2 rounded-lg cursor-pointer bg-white"
|
|
|
|
>
|
2022-04-06 01:11:29 +08:00
|
|
|
<input
|
2022-04-08 03:36:49 +08:00
|
|
|
bind:checked={value}
|
2022-04-06 01:11:29 +08:00
|
|
|
{disabled}
|
|
|
|
type="checkbox"
|
|
|
|
name="test"
|
2022-04-21 17:27:12 +08:00
|
|
|
class="rounded border-gray-300 text-blue-600 disabled:text-gray-400 disabled:!cursor-not-allowed shadow-sm focus:border-blue-300 focus:ring focus:ring-offset-0 focus:ring-blue-200 focus:ring-opacity-50"
|
2022-04-06 01:11:29 +08:00
|
|
|
/>
|
|
|
|
<span class="ml-2">{label}</span></label
|
2022-03-03 00:42:43 +08:00
|
|
|
>
|
2022-04-06 01:11:29 +08:00
|
|
|
</Block>
|