From f38dc71041ea6758067be533184877d554ab608d Mon Sep 17 00:00:00 2001 From: moonlitgrace Date: Sat, 15 Feb 2025 17:45:58 +0530 Subject: [PATCH] refactor: proper conditional rendering --- .../routes/(authentication)/+layout.svelte | 91 ++++++++++++------- 1 file changed, 58 insertions(+), 33 deletions(-) diff --git a/frontend/src/routes/(authentication)/+layout.svelte b/frontend/src/routes/(authentication)/+layout.svelte index 9ee5680..f663c56 100644 --- a/frontend/src/routes/(authentication)/+layout.svelte +++ b/frontend/src/routes/(authentication)/+layout.svelte @@ -2,14 +2,24 @@ import GoogleLogo from '$lib/components/icons/logos/google.svelte'; import QuibbleTextLogo from '$lib/components/icons/logos/quibble-text.svelte'; import QuibbleLogo from '$lib/components/icons/logos/quibble.svelte'; + import type { Nullable } from '$lib/types/shared'; import { setContext } from 'svelte'; + interface LoginData { + token?: string; + email?: string; + } + let { children } = $props(); + let login_data = $state(); + let show_profile_type = $state>(null); + setContext('handle_login_success', handle_login_success); function handle_login_success(data: { token: string; email: string }) { - console.log(data); + login_data = { ...data }; + show_profile_type = 'select'; } @@ -17,44 +27,59 @@
-
+
-

- Join in, share your take, and
make some waves! -

-
- -
- - - - + + {#if show_profile_type === 'select'} + Who's quibbling? + You can later switch b/w profiles from settings page + {:else if show_profile_type === 'create'} + Let's create a new one! + You can later switch b/w profiles from settings page + {:else} + Join in, share your take, and
make some waves! + {/if} +
-
OR
- - {@render children()} - -

- By continuing, you agree to the Terms of use, - Privacy - and Policy Preplaced. -

+ {#if show_profile_type === 'select'} +
Select profile
+ {:else if show_profile_type === 'create'} +
Profile create
+ {:else} + +
+ + + + +
+
OR
+ + {@render children()} + +

+ By continuing, you agree to the Terms of use, + Privacy + and Policy Preplaced. +

+ {/if}