From 2b58ff029107b23617d8c4b246de77876b3bf053 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 28 Sep 2022 00:21:37 +0800 Subject: feat: Move frontend into layout group (main) This enables /book to load without the usual layout (app layout) --- apps/kit/src/app.pcss | 12 ++ apps/kit/src/lib/components/alert.svelte | 6 +- apps/kit/src/lib/components/button.svelte | 59 +++--- apps/kit/src/lib/helpers.ts | 4 +- apps/kit/src/routes/(app)/+layout.svelte | 215 --------------------- apps/kit/src/routes/(app)/home/+page.svelte | 1 - apps/kit/src/routes/(main)/(app)/+layout.svelte | 215 +++++++++++++++++++++ apps/kit/src/routes/(main)/(app)/home/+page.svelte | 1 + apps/kit/src/routes/(main)/(public)/+layout.svelte | 1 + .../src/routes/(main)/(public)/login/+page.svelte | 136 +++++++++++++ .../src/routes/(main)/(public)/reset/+page.svelte | 104 ++++++++++ .../src/routes/(main)/(public)/signup/+page.svelte | 38 ++++ apps/kit/src/routes/(main)/+layout.server.ts | 13 ++ apps/kit/src/routes/(main)/+layout.svelte | 41 ++++ apps/kit/src/routes/(main)/+layout.ts | 9 + apps/kit/src/routes/(main)/+page.svelte | 2 + apps/kit/src/routes/(public)/+layout.svelte | 3 - apps/kit/src/routes/(public)/login/+page.svelte | 136 ------------- apps/kit/src/routes/(public)/reset/+page.svelte | 104 ---------- apps/kit/src/routes/(public)/signup/+page.svelte | 38 ---- apps/kit/src/routes/+layout.server.ts | 13 -- apps/kit/src/routes/+layout.svelte | 41 ---- apps/kit/src/routes/+layout.ts | 9 - apps/kit/src/routes/+page.svelte | 2 - apps/kit/src/routes/book/+layout.svelte | 17 +- apps/kit/src/routes/book/alerts/+page.svelte | 4 +- apps/kit/src/routes/book/buttons/+page.svelte | 24 +++ 27 files changed, 654 insertions(+), 594 deletions(-) delete mode 100644 apps/kit/src/routes/(app)/+layout.svelte delete mode 100644 apps/kit/src/routes/(app)/home/+page.svelte create mode 100644 apps/kit/src/routes/(main)/(app)/+layout.svelte create mode 100644 apps/kit/src/routes/(main)/(app)/home/+page.svelte create mode 100644 apps/kit/src/routes/(main)/(public)/+layout.svelte create mode 100644 apps/kit/src/routes/(main)/(public)/login/+page.svelte create mode 100644 apps/kit/src/routes/(main)/(public)/reset/+page.svelte create mode 100644 apps/kit/src/routes/(main)/(public)/signup/+page.svelte create mode 100644 apps/kit/src/routes/(main)/+layout.server.ts create mode 100644 apps/kit/src/routes/(main)/+layout.svelte create mode 100644 apps/kit/src/routes/(main)/+layout.ts create mode 100644 apps/kit/src/routes/(main)/+page.svelte delete mode 100644 apps/kit/src/routes/(public)/+layout.svelte delete mode 100644 apps/kit/src/routes/(public)/login/+page.svelte delete mode 100644 apps/kit/src/routes/(public)/reset/+page.svelte delete mode 100644 apps/kit/src/routes/(public)/signup/+page.svelte delete mode 100644 apps/kit/src/routes/+layout.server.ts delete mode 100644 apps/kit/src/routes/+layout.svelte delete mode 100644 apps/kit/src/routes/+layout.ts delete mode 100644 apps/kit/src/routes/+page.svelte create mode 100644 apps/kit/src/routes/book/buttons/+page.svelte (limited to 'apps') diff --git a/apps/kit/src/app.pcss b/apps/kit/src/app.pcss index 78a8e0b..d256fea 100644 --- a/apps/kit/src/app.pcss +++ b/apps/kit/src/app.pcss @@ -20,3 +20,15 @@ pre { .c-disabled.loading { cursor: wait !important; } + +.link { + @apply text-blue-600 hover:text-blue-700 transition duration-300 ease-in-out mb-4; + + &.danger { + @apply text-red-600 hover:text-red-700; + } + + &.active { + @apply underline + } +} \ No newline at end of file diff --git a/apps/kit/src/lib/components/alert.svelte b/apps/kit/src/lib/components/alert.svelte index 6cc0e63..5bcb3ae 100644 --- a/apps/kit/src/lib/components/alert.svelte +++ b/apps/kit/src/lib/components/alert.svelte @@ -17,12 +17,12 @@ let iconComponent: any; let colorClassPart = ""; - // if no unique id is supplied, cooldown will not work between page loads. - // Therefore we are disabling it with noCooldownSetting in the fallback id. /** * An optional id for this alert, a default is set if not specified. * This value is necessary for closeable cooldown to work. */ + // if no unique id is supplied, cooldown will not work between page loads. + // Therefore we are disabling it with noCooldownSetting in the fallback id. export let id = "alert--" + noCooldownSetting + "--" + random_string(4); /** * The title to communicate, value is optional @@ -42,7 +42,7 @@ export let closeable = false; /** * The amount of seconds that should go by before this alert is shown again, only works when a unique id is set. - * Set to ~ if it should be only shown once per client (State stored in localestorage). + * Set to ~ if it should only be shown once per client (State stored in localestorage). **/ export let closeableCooldown = "-1"; /** diff --git a/apps/kit/src/lib/components/button.svelte b/apps/kit/src/lib/components/button.svelte index 5550e5e..6566cec 100644 --- a/apps/kit/src/lib/components/button.svelte +++ b/apps/kit/src/lib/components/button.svelte @@ -1,19 +1,23 @@ - + + + {#if href && !disabled} - + + {text} {:else} - -{/if} \ No newline at end of file +{/if} diff --git a/apps/kit/src/lib/helpers.ts b/apps/kit/src/lib/helpers.ts index c2a811e..c4e2e51 100644 --- a/apps/kit/src/lib/helpers.ts +++ b/apps/kit/src/lib/helpers.ts @@ -123,7 +123,9 @@ export function set_favicon(url: string) { document.head.appendChild(link); } } - +export function no_type_check(x: any) { + return x; +} export function capitalise(value: string): string { return value.charAt(0).toUpperCase() + value.slice(1); } diff --git a/apps/kit/src/routes/(app)/+layout.svelte b/apps/kit/src/routes/(app)/+layout.svelte deleted file mode 100644 index 3f60af3..0000000 --- a/apps/kit/src/routes/(app)/+layout.svelte +++ /dev/null @@ -1,215 +0,0 @@ - - - -{#if !online} -
-
-
- -
-
-

- You seem to be offline, please check your internet connection. -

-
-
-
-{/if} -
- - sidebarIsOpen = !sidebarIsOpen}> - -
-
- -
- - - -
- -
-
- - -
-
- -
-
-
- - - -
-
-
-
- -
-
-
-
-
- - -
- -
-
-
\ No newline at end of file diff --git a/apps/kit/src/routes/(app)/home/+page.svelte b/apps/kit/src/routes/(app)/home/+page.svelte deleted file mode 100644 index 247ee47..0000000 --- a/apps/kit/src/routes/(app)/home/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -

Welcome Home

\ No newline at end of file diff --git a/apps/kit/src/routes/(main)/(app)/+layout.svelte b/apps/kit/src/routes/(main)/(app)/+layout.svelte new file mode 100644 index 0000000..3f60af3 --- /dev/null +++ b/apps/kit/src/routes/(main)/(app)/+layout.svelte @@ -0,0 +1,215 @@ + + + +{#if !online} +
+
+
+ +
+
+

+ You seem to be offline, please check your internet connection. +

+
+
+
+{/if} +
+ + sidebarIsOpen = !sidebarIsOpen}> + +
+
+ +
+ + + +
+ +
+
+ + +
+
+ +
+
+
+ + + +
+
+
+
+ +
+
+
+
+
+ + +
+ +
+
+
\ No newline at end of file diff --git a/apps/kit/src/routes/(main)/(app)/home/+page.svelte b/apps/kit/src/routes/(main)/(app)/home/+page.svelte new file mode 100644 index 0000000..247ee47 --- /dev/null +++ b/apps/kit/src/routes/(main)/(app)/home/+page.svelte @@ -0,0 +1 @@ +

Welcome Home

\ No newline at end of file diff --git a/apps/kit/src/routes/(main)/(public)/+layout.svelte b/apps/kit/src/routes/(main)/(public)/+layout.svelte new file mode 100644 index 0000000..49aeb95 --- /dev/null +++ b/apps/kit/src/routes/(main)/(public)/+layout.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/kit/src/routes/(main)/(public)/login/+page.svelte b/apps/kit/src/routes/(main)/(public)/login/+page.svelte new file mode 100644 index 0000000..9e2f6e7 --- /dev/null +++ b/apps/kit/src/routes/(main)/(public)/login/+page.svelte @@ -0,0 +1,136 @@ + + +
+
+

+ {$LL.login.loginToYourAccount()} +

+

+ {$LL.common.or()} + {$LL.login.createANewAccount()} +

+
+
+
+ {#if error.text || error.title} +
+ {#if error.title} +

+ {error.title} +

+ {/if} + {#if error.text} +
+ {error.text} +
+ {/if} +
+ {/if} +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ + +
+ + +
+ +
+ +
+
+
+
+
diff --git a/apps/kit/src/routes/(main)/(public)/reset/+page.svelte b/apps/kit/src/routes/(main)/(public)/reset/+page.svelte new file mode 100644 index 0000000..5092b4b --- /dev/null +++ b/apps/kit/src/routes/(main)/(public)/reset/+page.svelte @@ -0,0 +1,104 @@ + + +
+
+

+ {$LL.reset.resetPassword()} +

+

+ {$LL.common.or()} + {$LL.reset.gotoLoginPage().toLowerCase()} +

+
+ +
+
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+
diff --git a/apps/kit/src/routes/(main)/(public)/signup/+page.svelte b/apps/kit/src/routes/(main)/(public)/signup/+page.svelte new file mode 100644 index 0000000..d4a1bda --- /dev/null +++ b/apps/kit/src/routes/(main)/(public)/signup/+page.svelte @@ -0,0 +1,38 @@ +
+
+

Create your new account

+

+ Or + go to login page +

+
+ +
+
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+
+
diff --git a/apps/kit/src/routes/(main)/+layout.server.ts b/apps/kit/src/routes/(main)/+layout.server.ts new file mode 100644 index 0000000..01aae89 --- /dev/null +++ b/apps/kit/src/routes/(main)/+layout.server.ts @@ -0,0 +1,13 @@ +// import {is_active} from "$lib/session"; +// import {redirect} from "@sveltejs/kit"; +// import type {LayoutServerLoad} from "./$types"; +// +// export const load: LayoutServerLoad = async ({routeId}) => { +// const sessionIsValid = await is_active(); +// const isPublicRoute = routeId?.startsWith("(public)"); +// if (sessionIsValid && isPublicRoute) { +// throw redirect(302, "/home"); +// } else if (!sessionIsValid && !isPublicRoute) { +// throw redirect(302, "/login"); +// } +// }; \ No newline at end of file diff --git a/apps/kit/src/routes/(main)/+layout.svelte b/apps/kit/src/routes/(main)/+layout.svelte new file mode 100644 index 0000000..e5b177e --- /dev/null +++ b/apps/kit/src/routes/(main)/+layout.svelte @@ -0,0 +1,41 @@ + + + + diff --git a/apps/kit/src/routes/(main)/+layout.ts b/apps/kit/src/routes/(main)/+layout.ts new file mode 100644 index 0000000..de8a5c0 --- /dev/null +++ b/apps/kit/src/routes/(main)/+layout.ts @@ -0,0 +1,9 @@ +import type {Locales} from "$lib/i18n/i18n-types"; +import {loadLocaleAsync} from "$lib/i18n/i18n-util.async"; +import type {LayoutLoad} from "./$types"; + +export const load: LayoutLoad<{ locale: Locales }> = async ({url, params}) => { + let lang = "en" as Locales; + await loadLocaleAsync(lang); + return {locale: lang}; +}; \ No newline at end of file diff --git a/apps/kit/src/routes/(main)/+page.svelte b/apps/kit/src/routes/(main)/+page.svelte new file mode 100644 index 0000000..85a4d2d --- /dev/null +++ b/apps/kit/src/routes/(main)/+page.svelte @@ -0,0 +1,2 @@ + +

Hold on...

diff --git a/apps/kit/src/routes/(public)/+layout.svelte b/apps/kit/src/routes/(public)/+layout.svelte deleted file mode 100644 index 84cd442..0000000 --- a/apps/kit/src/routes/(public)/+layout.svelte +++ /dev/null @@ -1,3 +0,0 @@ - - \ No newline at end of file diff --git a/apps/kit/src/routes/(public)/login/+page.svelte b/apps/kit/src/routes/(public)/login/+page.svelte deleted file mode 100644 index 9e2f6e7..0000000 --- a/apps/kit/src/routes/(public)/login/+page.svelte +++ /dev/null @@ -1,136 +0,0 @@ - - -
-
-

- {$LL.login.loginToYourAccount()} -

-

- {$LL.common.or()} - {$LL.login.createANewAccount()} -

-
-
-
- {#if error.text || error.title} -
- {#if error.title} -

- {error.title} -

- {/if} - {#if error.text} -
- {error.text} -
- {/if} -
- {/if} -
-
- -
- -
-
- -
- -
- -
-
- -
-
- - -
- - -
- -
- -
-
-
-
-
diff --git a/apps/kit/src/routes/(public)/reset/+page.svelte b/apps/kit/src/routes/(public)/reset/+page.svelte deleted file mode 100644 index 5092b4b..0000000 --- a/apps/kit/src/routes/(public)/reset/+page.svelte +++ /dev/null @@ -1,104 +0,0 @@ - - -
-
-

- {$LL.reset.resetPassword()} -

-

- {$LL.common.or()} - {$LL.reset.gotoLoginPage().toLowerCase()} -

-
- -
-
-
- - - -
- -
- -
-
-
- -
- -
-
-
diff --git a/apps/kit/src/routes/(public)/signup/+page.svelte b/apps/kit/src/routes/(public)/signup/+page.svelte deleted file mode 100644 index d4a1bda..0000000 --- a/apps/kit/src/routes/(public)/signup/+page.svelte +++ /dev/null @@ -1,38 +0,0 @@ -
-
-

Create your new account

-

- Or - go to login page -

-
- -
-
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
-
-
-
-
diff --git a/apps/kit/src/routes/+layout.server.ts b/apps/kit/src/routes/+layout.server.ts deleted file mode 100644 index 01aae89..0000000 --- a/apps/kit/src/routes/+layout.server.ts +++ /dev/null @@ -1,13 +0,0 @@ -// import {is_active} from "$lib/session"; -// import {redirect} from "@sveltejs/kit"; -// import type {LayoutServerLoad} from "./$types"; -// -// export const load: LayoutServerLoad = async ({routeId}) => { -// const sessionIsValid = await is_active(); -// const isPublicRoute = routeId?.startsWith("(public)"); -// if (sessionIsValid && isPublicRoute) { -// throw redirect(302, "/home"); -// } else if (!sessionIsValid && !isPublicRoute) { -// throw redirect(302, "/login"); -// } -// }; \ No newline at end of file diff --git a/apps/kit/src/routes/+layout.svelte b/apps/kit/src/routes/+layout.svelte deleted file mode 100644 index f8cdf83..0000000 --- a/apps/kit/src/routes/+layout.svelte +++ /dev/null @@ -1,41 +0,0 @@ - - - - diff --git a/apps/kit/src/routes/+layout.ts b/apps/kit/src/routes/+layout.ts deleted file mode 100644 index de8a5c0..0000000 --- a/apps/kit/src/routes/+layout.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type {Locales} from "$lib/i18n/i18n-types"; -import {loadLocaleAsync} from "$lib/i18n/i18n-util.async"; -import type {LayoutLoad} from "./$types"; - -export const load: LayoutLoad<{ locale: Locales }> = async ({url, params}) => { - let lang = "en" as Locales; - await loadLocaleAsync(lang); - return {locale: lang}; -}; \ No newline at end of file diff --git a/apps/kit/src/routes/+page.svelte b/apps/kit/src/routes/+page.svelte deleted file mode 100644 index 85a4d2d..0000000 --- a/apps/kit/src/routes/+page.svelte +++ /dev/null @@ -1,2 +0,0 @@ - -

Hold on...

diff --git a/apps/kit/src/routes/book/+layout.svelte b/apps/kit/src/routes/book/+layout.svelte index 0fcbd51..85ba907 100644 --- a/apps/kit/src/routes/book/+layout.svelte +++ b/apps/kit/src/routes/book/+layout.svelte @@ -1,9 +1,22 @@
-