From ff51a7bfbf71aebfe692aad3651152837a410ef0 Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 26 Mar 2026 11:47:42 -0400 Subject: [PATCH] refactor contact form - Change positions of submit button and turnstile widget - Turnstile widget only appears on interaction with contact form --- src/components/svelte/ContactForm.svelte | 45 ++++++++++++++---------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/components/svelte/ContactForm.svelte b/src/components/svelte/ContactForm.svelte index ead2224..f1acd3a 100644 --- a/src/components/svelte/ContactForm.svelte +++ b/src/components/svelte/ContactForm.svelte @@ -15,10 +15,14 @@ let errorMessage = $state('') let turnstileWidgetId: string | null = $state(null) let turnstileContainer: HTMLElement + let turnstileInitialized = false const TURNSTILE_SITEKEY = sitekey - onMount(() => { + function initTurnstile() { + if (turnstileInitialized) return + turnstileInitialized = true + // Wait for Turnstile script to load const interval = setInterval(() => { if (typeof window.turnstile !== 'undefined') { @@ -32,9 +36,10 @@ }) } }, 100) + } + onMount(() => { return () => { - clearInterval(interval) if (turnstileWidgetId !== null && typeof window.turnstile !== 'undefined') { window.turnstile.remove(turnstileWidgetId) } @@ -111,7 +116,7 @@ } -
+
- -
+ {#if formState === 'success'}
@@ -174,17 +178,22 @@
{/if} - +
+ +
+ + +