From 94b31717f09d384686c9313e5123c6b561c17e86 Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Fri, 9 Jul 2021 23:43:26 +0700 Subject: [PATCH] chore(wip): work --- client/src/components/navbar.svelte | 3 + client/src/hooks.ts | 1 + client/src/lib/Counter/index.svelte | 98 --------------------- client/src/lib/Header/index.svelte | 120 -------------------------- client/src/lib/Header/svelte-logo.svg | 1 - client/src/lib/form.ts | 60 ------------- client/src/lib/types.d.ts | 7 -- client/src/locale.ts | 7 ++ client/src/routes/__layout.svelte | 74 ++++++++-------- client/src/routes/api.svelte | 4 + client/src/routes/guide.svelte | 3 + client/src/routes/index.svelte | 45 +--------- 12 files changed, 56 insertions(+), 367 deletions(-) create mode 100644 client/src/components/navbar.svelte delete mode 100644 client/src/lib/Counter/index.svelte delete mode 100644 client/src/lib/Header/index.svelte delete mode 100644 client/src/lib/Header/svelte-logo.svg delete mode 100644 client/src/lib/form.ts delete mode 100644 client/src/lib/types.d.ts create mode 100644 client/src/locale.ts create mode 100644 client/src/routes/api.svelte create mode 100644 client/src/routes/guide.svelte diff --git a/client/src/components/navbar.svelte b/client/src/components/navbar.svelte new file mode 100644 index 0000000..f1e4cb7 --- /dev/null +++ b/client/src/components/navbar.svelte @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/client/src/hooks.ts b/client/src/hooks.ts index ae4039e..7140f07 100644 --- a/client/src/hooks.ts +++ b/client/src/hooks.ts @@ -1,3 +1,4 @@ +// TODO: Find out what the fuck this file is doing import cookie from 'cookie'; import { v4 as uuid } from '@lukeed/uuid'; import type { Handle } from '@sveltejs/kit'; diff --git a/client/src/lib/Counter/index.svelte b/client/src/lib/Counter/index.svelte deleted file mode 100644 index ae70bc3..0000000 --- a/client/src/lib/Counter/index.svelte +++ /dev/null @@ -1,98 +0,0 @@ - - -
- - -
-
- - {Math.floor($displayed_count)} -
-
- - -
- - diff --git a/client/src/lib/Header/index.svelte b/client/src/lib/Header/index.svelte deleted file mode 100644 index b9b795b..0000000 --- a/client/src/lib/Header/index.svelte +++ /dev/null @@ -1,120 +0,0 @@ - - -
-
- - SvelteKit - -
- - - -
- -
-
- - diff --git a/client/src/lib/Header/svelte-logo.svg b/client/src/lib/Header/svelte-logo.svg deleted file mode 100644 index 49492a8..0000000 --- a/client/src/lib/Header/svelte-logo.svg +++ /dev/null @@ -1 +0,0 @@ -svelte-logo \ No newline at end of file diff --git a/client/src/lib/form.ts b/client/src/lib/form.ts deleted file mode 100644 index abbc575..0000000 --- a/client/src/lib/form.ts +++ /dev/null @@ -1,60 +0,0 @@ -// this action (https://svelte.dev/tutorial/actions) allows us to -// progressively enhance a
that already works without JS -export function enhance( - form: HTMLFormElement, - { - pending, - error, - result, - }: { - pending?: (data: FormData, form: HTMLFormElement) => void; - error?: (res: Response, error: Error, form: HTMLFormElement) => void; - result: (res: Response, form: HTMLFormElement) => void; - } -) { - let current_token: Record; - - async function handle_submit(e: Event) { - const token = (current_token = {}); - - e.preventDefault(); - - const body = new FormData(form); - - if (pending) pending(body, form); - - try { - const res = await fetch(form.action, { - method: form.method, - headers: { - accept: 'application/json', - }, - body, - }); - - if (token !== current_token) return; - - if (res.ok) { - result(res, form); - } else if (error) { - error(res, null, form); - } else { - console.error(await res.text()); - } - } catch (e) { - if (error) { - error(null, e, form); - } else { - throw e; - } - } - } - - form.addEventListener('submit', handle_submit); - - return { - destroy() { - form.removeEventListener('submit', handle_submit); - }, - }; -} diff --git a/client/src/lib/types.d.ts b/client/src/lib/types.d.ts deleted file mode 100644 index 7798432..0000000 --- a/client/src/lib/types.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Can be made globally available by placing this - * inside `global.d.ts` and removing `export` keyword - */ -export interface Locals { - userid: string; -} diff --git a/client/src/locale.ts b/client/src/locale.ts new file mode 100644 index 0000000..5b28346 --- /dev/null +++ b/client/src/locale.ts @@ -0,0 +1,7 @@ +/** + * TODO: Check user locale, then determines whether they should go to english route or indonesian route. + */ + +const getLanguage = () => navigator?.languages[0] || navigator?.language || 'en'; + +export {} \ No newline at end of file diff --git a/client/src/routes/__layout.svelte b/client/src/routes/__layout.svelte index 07e321b..ecc0830 100644 --- a/client/src/routes/__layout.svelte +++ b/client/src/routes/__layout.svelte @@ -1,46 +1,46 @@ -
-
- -
+
+ +
+
+ +
- + - -
+ } + diff --git a/client/src/routes/api.svelte b/client/src/routes/api.svelte new file mode 100644 index 0000000..cda8e7c --- /dev/null +++ b/client/src/routes/api.svelte @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/client/src/routes/guide.svelte b/client/src/routes/guide.svelte new file mode 100644 index 0000000..ee9a011 --- /dev/null +++ b/client/src/routes/guide.svelte @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/client/src/routes/index.svelte b/client/src/routes/index.svelte index c2cbbe4..3f327f9 100644 --- a/client/src/routes/index.svelte +++ b/client/src/routes/index.svelte @@ -3,57 +3,14 @@ Home -
-

-
- - - Welcome - -
- - to your new
SvelteKit app -

- -

- try editing src/routes/index.svelte -

- - +