refactor(checkbox): make classes reactive

This commit is contained in:
Eric Liu 2019-12-29 18:52:20 -08:00
commit 60d9258d0b
4 changed files with 29 additions and 25 deletions

View file

@ -8,6 +8,8 @@
const { labelText, indeterminate, disabled, hideLabel, wrapperClassName } = $$props;
const checkboxProps = { labelText, indeterminate, disabled, hideLabel, wrapperClassName };
let checked = true;
</script>
<Layout>
@ -22,8 +24,14 @@
{:else}
<fieldset class={cx('--fieldset')}>
<legend class={cx('--label')}>Checkbox heading</legend>
<Checkbox {...checkboxProps} checked id="checkbox-label-1" />
<Checkbox {...checkboxProps} checked id="checkbox-label-2" />
<Checkbox
{...checkboxProps}
id="checkbox-label-1"
bind:checked
on:check={({ detail }) => {
console.log('on:check', detail);
}} />
<Checkbox {...checkboxProps} id="checkbox-label-2" checked />
</fieldset>
{/if}
</Layout>