Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass $$restProps to button #1339

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/lib/buttons/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
export let shadow: boolean = false;
export let tag: string = 'button';
export let checked: boolean | undefined = undefined;
// export let disabled: boolean = false;
export let disabled: boolean = false;

const colorClasses = {
alternative: 'text-gray-900 bg-white border border-gray-200 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-400 hover:text-primary-700 focus-within:text-primary-700 dark:focus-within:text-white dark:hover:text-white dark:hover:bg-gray-700',
Expand Down Expand Up @@ -113,21 +113,21 @@
group ? (pill && 'first:rounded-s-full last:rounded-e-full') || 'first:rounded-s-lg last:rounded-e-lg' : (pill && 'rounded-full') || 'rounded-lg',
shadow && 'shadow-lg',
shadow && coloredShadowClasses[color],
$$restProps.disabled && 'cursor-not-allowed opacity-50',
disabled && 'cursor-not-allowed opacity-50',
$$props.class
);
</script>

{#if href && !$$restProps.disabled}
{#if href && !disabled}
<a {href} {...$$restProps} class={buttonClass} role="button" on:click on:change on:keydown on:keyup on:touchstart|passive on:touchend on:touchcancel on:mouseenter on:mouseleave>
<slot />
</a>
{:else if tag === 'button' && !$$restProps.disabled }
<button {type} {...$$restProps} class={buttonClass} on:click on:change on:keydown on:keyup on:touchstart|passive on:touchend on:touchcancel on:mouseenter on:mouseleave>
{:else if tag === 'button' }
<button {type} {...$$restProps} {disabled} class={buttonClass} on:click on:change on:keydown on:keyup on:touchstart|passive on:touchend on:touchcancel on:mouseenter on:mouseleave>
<slot />
</button>
{:else}
<svelte:element this={tag} class={buttonClass}>
<svelte:element this={tag} {...$$restProps} class={buttonClass}>
<slot />
</svelte:element>
{/if}
Expand Down