Files
classroomio/apps/dashboard/src/lib/components/Form/Checkbox.svelte
T

43 lines
996 B
Svelte
Raw Normal View History

<script>
import TextField from '$lib/components/Form/TextField.svelte';
export let label;
export let value;
export let checked;
export let name;
export let isEditable = false;
2021-07-06 08:39:17 +03:00
export let disabled = false;
2021-07-22 08:04:48 +03:00
export let className = '';
2021-08-18 19:47:02 +03:00
export let onChange;
</script>
2021-07-06 08:39:17 +03:00
<label
2021-07-22 08:04:48 +03:00
class="{className} inline-flex items-center w-full {disabled
2021-07-06 08:39:17 +03:00
? 'cursor-not-allowed'
: 'cursor-pointer'}"
>
<input
type="checkbox"
class="rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-offset-0 focus:ring-indigo-200 focus:ring-opacity-50"
{name}
{value}
2021-07-06 08:39:17 +03:00
disabled={disabled || isEditable}
bind:checked
/>
{#if isEditable}
<div class="w-2/4">
<TextField
bind:value={label}
placeholder="Your option"
className="ml-1"
type="text"
{onChange}
/>
</div>
{:else}
<span class="dark:text-white ml-2">{label}</span>
{/if}
<slot name="iconbutton" />
</label>