Skip to content

Commit

Permalink
add $bindable prop el to Pending_Button (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn authored Jun 10, 2024
1 parent 68869de commit b36a087
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-zoos-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ryanatkn/fuz': patch
---

add `$bindable` prop `el` to `Pending_Button`
27 changes: 24 additions & 3 deletions src/lib/Pending_Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,36 @@
title?: string;
disabled?: boolean;
attrs?: any;
el?: HTMLButtonElement | undefined;
children: Snippet;
}
// TODO maybe this shouldn't disable? cancelable?
let {
pending, // eslint-disable-line prefer-const
onclick, // eslint-disable-line prefer-const
running, // eslint-disable-line prefer-const
title, // eslint-disable-line prefer-const
disabled, // eslint-disable-line prefer-const
attrs, // eslint-disable-line prefer-const
el = $bindable(),
children, // eslint-disable-line prefer-const
}: Props = $props();
const {pending, onclick, running, title, disabled, attrs, children}: Props = $props();
el; // TODO @see https://github.com/sveltejs/language-tools/issues/2268
// TODO maybe this shouldn't disable? just visually look disabled, maybe with `.disabled`?
// TODO cancelable?
</script>

<button type="button" {...attrs} disabled={disabled ?? pending} {title} class:pending {onclick}>
<button
bind:this={el}
type="button"
{...attrs}
disabled={disabled ?? pending}
{title}
class:pending
{onclick}
>
<span class="content">
{@render children()}
</span>
Expand Down

0 comments on commit b36a087

Please sign in to comment.