From aebf6cd1494846d6c0e8323e56d379f3f8710a0e Mon Sep 17 00:00:00 2001 From: Jake Date: Thu, 7 May 2026 10:06:06 +0100 Subject: [PATCH] feat(toggle): add disabled, loading, and async onChange props Extends the shared Toggle with three optional props while keeping the existing bind:checked path untouched for current call sites. - disabled: dims the control, sets aria-disabled, and early-returns on click. - loading: forces a Loader2 spinner inside the thumb, applies cursor-wait and aria-busy, and blocks interaction. Cursor-wait wins over disabled's not-allowed when both are set, matching loading-precedence guidance. - onChange(next): when supplied, replaces the immediate flip. Promise returns drive an internal pending flag so the toggle renders loading while the handler resolves; on resolve checked flips, on reject the toggle snaps back. Synchronous handlers flip immediately after the call. Brand motion preserved: 150ms duration, cubic-bezier(0.2, 0.8, 0.2, 1), no transition-all. --- src/lib/components/Toggle.svelte | 73 +++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/src/lib/components/Toggle.svelte b/src/lib/components/Toggle.svelte index ffa2896..e8d3f87 100644 --- a/src/lib/components/Toggle.svelte +++ b/src/lib/components/Toggle.svelte @@ -1,21 +1,84 @@

{label}