Assorted fixes

Type fixes, support a couple more classes as functions for the examples, and switch TabPanels to registering ids instead of refs
This commit is contained in:
Ryan Gossiaux
2021-12-17 14:22:19 -08:00
parent 6076a60837
commit c5ed870827
6 changed files with 37 additions and 19 deletions

View File

@@ -44,25 +44,35 @@
"aria-labelledby": $labelContext?.labelIds,
"aria-describedby": $descriptionContext?.descriptionIds,
};
$: classStyle = $$props.class
? typeof $$props.class === "function"
? $$props.class({
checked,
})
: $$props.class
: "";
</script>
{#if switchStore}
<button
{...{ ...$$restProps, ...propsWeControl }}
bind:this={$switchStore}
class={classStyle}
on:click={handleClick}
on:keyup={handleKeyUp}
on:keypress={handleKeyPress}
>
<slot />
<slot {checked} />
</button>
{:else}
<button
{...{ ...$$restProps, ...propsWeControl }}
class={classStyle}
on:click={handleClick}
on:keyup={handleKeyUp}
on:keypress={handleKeyPress}
>
<slot />
<slot {checked} />
</button>
{/if}