From e96783230eb883176eb9f4a6bf64349374f3a2ed Mon Sep 17 00:00:00 2001 From: Bart van der Braak Date: Mon, 19 Feb 2024 19:07:32 +0100 Subject: [PATCH] refactor: separate components for auth --- src/routes/(auth)/auth/(components)/index.ts | 3 + .../auth/(components)/login-form.svelte | 63 +++++ .../auth/(components)/register-form.svelte | 67 +++++ .../(auth)/auth/(components)/sso-form.svelte | 115 +++++++++ src/routes/(auth)/auth/+page.svelte | 241 +----------------- 5 files changed, 255 insertions(+), 234 deletions(-) create mode 100644 src/routes/(auth)/auth/(components)/index.ts create mode 100644 src/routes/(auth)/auth/(components)/login-form.svelte create mode 100644 src/routes/(auth)/auth/(components)/register-form.svelte create mode 100644 src/routes/(auth)/auth/(components)/sso-form.svelte diff --git a/src/routes/(auth)/auth/(components)/index.ts b/src/routes/(auth)/auth/(components)/index.ts new file mode 100644 index 0000000..14e9bda --- /dev/null +++ b/src/routes/(auth)/auth/(components)/index.ts @@ -0,0 +1,3 @@ +export { default as LoginForm } from './login-form.svelte'; +export { default as RegisterForm } from './register-form.svelte'; +export { default as SSOForm } from './sso-form.svelte'; diff --git a/src/routes/(auth)/auth/(components)/login-form.svelte b/src/routes/(auth)/auth/(components)/login-form.svelte new file mode 100644 index 0000000..132e806 --- /dev/null +++ b/src/routes/(auth)/auth/(components)/login-form.svelte @@ -0,0 +1,63 @@ + + +
+

Log into your account

+

+ Enter your credentials below to log into your account +

+
+
+
{ + isLoading = true; + return async ({ update }) => { + isLoading = false; + update(); + }; + }} + > +
+
+ + +
+
+ + +
+ +
+ {#if form?.notVerified} + + You must verify your email before you can log in. + + {/if} +
+
diff --git a/src/routes/(auth)/auth/(components)/register-form.svelte b/src/routes/(auth)/auth/(components)/register-form.svelte new file mode 100644 index 0000000..b71ba1d --- /dev/null +++ b/src/routes/(auth)/auth/(components)/register-form.svelte @@ -0,0 +1,67 @@ + + +
+

Create your account

+

+ Enter your details below to create a new account +

+
+
+
{ + isLoading = true; + return async ({ update }) => { + isLoading = false; + update(); + }; + }} + > +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
diff --git a/src/routes/(auth)/auth/(components)/sso-form.svelte b/src/routes/(auth)/auth/(components)/sso-form.svelte new file mode 100644 index 0000000..05f5ea7 --- /dev/null +++ b/src/routes/(auth)/auth/(components)/sso-form.svelte @@ -0,0 +1,115 @@ + + +
{ + isLoading = true; + return async ({ update }) => { + isLoading = false; + update(); + }; + }} +> +
+
+ +
+
+ Or continue with +
+
+
+ +
+ +
+ {#if providers.length > 1} +
+ +
+ + + + + + Login Providers + {#each providers as provider} + {#if provider.name !== currentProvider.name} + (currentProvider = provider)} + > + {#if provider.icon === undefined} + {provider.name} + {:else} + + {/if} + {provider.displayName} + + {/if} + {/each} + + +
+
+ {/if} +
+
diff --git a/src/routes/(auth)/auth/+page.svelte b/src/routes/(auth)/auth/+page.svelte index 55c6c01..dd92484 100644 --- a/src/routes/(auth)/auth/+page.svelte +++ b/src/routes/(auth)/auth/+page.svelte @@ -1,48 +1,19 @@