From 125d7d997e742b3c65faca50b0c5a552333c5654 Mon Sep 17 00:00:00 2001 From: Samuel Andert Date: Tue, 1 Aug 2023 11:58:34 +0200 Subject: [PATCH] Added Basic xstate store management POC --- src/lib/components/Balance.svelte | 2 +- src/lib/components/Wallet/Wallet.svelte | 2 + .../examples/CheckValidation.svelte | 14 + src/lib/components/examples/Form.svelte | 240 ++++++++++-------- src/lib/components/examples/bugs.md | 8 - src/lib/components/examples/feedback.md | 1 + src/lib/services/validationRecipe.ts | 27 ++ src/lib/types/UserSchema.ts | 2 +- src/routes/form/+page.svelte | 39 +++ src/routes/helloearth/+page.svelte | 2 +- 10 files changed, 224 insertions(+), 113 deletions(-) create mode 100644 src/lib/components/examples/CheckValidation.svelte delete mode 100644 src/lib/components/examples/bugs.md create mode 100644 src/lib/components/examples/feedback.md create mode 100644 src/lib/services/validationRecipe.ts create mode 100644 src/routes/form/+page.svelte diff --git a/src/lib/components/Balance.svelte b/src/lib/components/Balance.svelte index 8a04bd6..6fc53d5 100644 --- a/src/lib/components/Balance.svelte +++ b/src/lib/components/Balance.svelte @@ -1,4 +1,4 @@ - + +
+ {#if $store.isValidated} +
+ {:else} +
+ {/if} +
diff --git a/src/lib/components/examples/Form.svelte b/src/lib/components/examples/Form.svelte index ad26853..24b50bc 100644 --- a/src/lib/components/examples/Form.svelte +++ b/src/lib/components/examples/Form.svelte @@ -1,10 +1,16 @@ -
- {#if $successMessage} - - - {:else} -
- {#each fields as field} -
- {#if $errors[field]} - {$errors[field]} - {:else} - +
+ STORE: {JSON.stringify($store)} + {#if $successMessage} + + + {:else} + + {#each fields as field} +
+ {#if $errors[field]} + {$errors[field]} + {:else} + + {/if} - {#if field === 'about'} -