diff options
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/[username]/(profile)/+page.svelte | 29 | ||||
| -rw-r--r-- | src/routes/(app)/account/[id]/+page.svelte | 4 | ||||
| -rw-r--r-- | src/routes/(app)/account/new/+page.svelte | 14 | ||||
| -rw-r--r-- | src/routes/(app)/logout/+page.server.ts | 2 | ||||
| -rw-r--r-- | src/routes/(app)/settings/+layout.svelte | 4 | ||||
| -rw-r--r-- | src/routes/(static)/+layout.svelte | 7 | ||||
| -rw-r--r-- | src/routes/(static)/login/+page.svelte | 2 | ||||
| -rw-r--r-- | src/routes/(static)/map/add/+page.svelte | 64 | ||||
| -rw-r--r-- | src/routes/(static)/register/+page.svelte | 96 | ||||
| -rw-r--r-- | src/routes/(static)/register/auth/+page.svelte | 4 |
10 files changed, 178 insertions, 48 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index 41bc2152..38d5a522 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -8,7 +8,7 @@ import { installPrompt, password } from "$lib/store"; import { afterNavigate, goto, invalidate, preloadData } from "$app/navigation"; import { page } from "$app/stores"; - import { versions, post, fail } from "$lib/utils"; + import { versions, post, fail, getCookie } from "$lib/utils"; let { data } = $props(); @@ -65,10 +65,19 @@ adding = false; }; + let installDismissed = $state(browser && localStorage.getItem("installDismissed") === "1"); + let showInstall = $derived($installPrompt && !installDismissed); + let install = async () => { if (!$installPrompt) return; await $installPrompt.prompt(); $installPrompt = null; + dismissInstall(); + }; + + let dismissInstall = () => { + installDismissed = true; + localStorage.setItem("installDismissed", "1"); }; let pubkey = $state(); @@ -124,18 +133,24 @@ <div class="text-sm">{$t("incident")}</div> {/if} - {#if $installPrompt} - <button class="btn btn-accent w-full lg:hidden" onclick={install}> - <iconify-icon noobserver icon="ph:download-bold" width="32"></iconify-icon> - {$t("user.install")} - </button> - {/if} </div> {/if} </div> <!-- <a href="/funder" class="btn">Funder</a> --> +{#if showInstall} + <div class="fixed inset-x-0 bottom-0 z-[100] p-4 pb-[calc(1rem+var(--safe-area-inset-bottom))] bg-base-100 border-t border-base-300 shadow-lg lg:hidden"> + <div class="max-w-xl mx-auto flex items-center gap-3"> + <div class="flex-1"> + <p class="font-semibold">Add Coinos to homescreen?</p> + </div> + <button class="btn btn-accent !w-auto px-6" onclick={install}>Yes</button> + <button class="btn !w-auto px-6" onclick={dismissInstall}>No</button> + </div> + </div> +{/if} + <div class="fixed inset-x-0 mx-auto flex bottom-16 px-4"> {#if user?.username !== subject.username && (!subject.anon || subject.lud16)} <a diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte index 0f712c7f..cae3d030 100644 --- a/src/routes/(app)/account/[id]/+page.svelte +++ b/src/routes/(app)/account/[id]/+page.svelte @@ -143,7 +143,7 @@ {:else} <img src="/images/icon.png" class="w-8 h-8" alt="Coinos" /> {/if} - {displayType} account + {$t("accounts.accountTitle", { type: displayType })} </h1> <div class="container w-full mx-auto text-lg px-4 max-w-xl space-y-2"> @@ -169,7 +169,7 @@ {#if currencyChanged} <div class="flex justify-between items-center"> - <span>Also update default currency to {currency}</span> + <span>{$t("accounts.updateCurrency", { currency })}</span> <Toggle id="updateUserCurrency" bind:value={updateUserCurrency} /> </div> {/if} diff --git a/src/routes/(app)/account/new/+page.svelte b/src/routes/(app)/account/new/+page.svelte index db0361f8..4ad1fddb 100644 --- a/src/routes/(app)/account/new/+page.svelte +++ b/src/routes/(app)/account/new/+page.svelte @@ -20,7 +20,7 @@ const { getWalletEntropy } = await import("$lib/walletEntropy"); const entropy = await getWalletEntropy(); if (!entropy) { - fail($t("accounts.failedToDecryptSeed")); + fail($t("accounts.failedToDecryptSeed") as string); creatingArk = false; return; } @@ -40,23 +40,23 @@ goto(`/${user.username}`); } catch (e: any) { console.log("Ark account creation failed", e); - fail(e.message || $t("accounts.failedToDecryptSeed")); + fail(e.message || ($t("accounts.failedToDecryptSeed") as string)); creatingArk = false; } }; </script> <div class="space-y-5"> - <h1 class="text-center text-3xl font-semibold">Choose account type</h1> + <h1 class="text-center text-3xl font-semibold">{$t("accounts.chooseAccountType")}</h1> <div class="container w-full mx-auto text-lg px-4 max-w-xl space-y-5"> <a href="/account/bitcoin" class="block"> <div class="card card-side shadow shadow-base-300 p-8 hover:bg-base-200 gap-4 items-center"> <iconify-icon noobserver icon="logos:bitcoin" width={48}></iconify-icon> <div> - <div class="text-xl">Bitcoin (On-chain)</div> + <div class="text-xl">{$t("accounts.bitcoinOnChain")}</div> <div class="text-secondary"> - Self-custodial Bitcoin wallet secured by a 12-word seed phrase + {$t("accounts.bitcoinOnChainDesc")} </div> </div> </div> @@ -70,9 +70,9 @@ <img src="/images/ark.png" class="w-12 h-12 rounded-full object-cover bg-neutral" alt="Ark" /> {/if} <div> - <div class="text-xl">Ark (Off-chain)</div> + <div class="text-xl">{$t("accounts.arkOffChain")}</div> <div class="text-secondary"> - Experimental layer 2 wallet offering low fees and fast settlement + {$t("accounts.arkOffChainDesc")} </div> </div> </div> diff --git a/src/routes/(app)/logout/+page.server.ts b/src/routes/(app)/logout/+page.server.ts index 0a8b5d3a..c8581e5f 100644 --- a/src/routes/(app)/logout/+page.server.ts +++ b/src/routes/(app)/logout/+page.server.ts @@ -15,5 +15,5 @@ export async function load({ cookies }) { cookies.set("sk", "", opts); cookies.set("theme", "", opts); cookies.set("sid", "", opts); - redirect(307, `/login?lang=${lang}`); + redirect(307, lang ? `/login?lang=${lang}` : "/login"); } diff --git a/src/routes/(app)/settings/+layout.svelte b/src/routes/(app)/settings/+layout.svelte index 99bdc4ce..29e9489c 100644 --- a/src/routes/(app)/settings/+layout.svelte +++ b/src/routes/(app)/settings/+layout.svelte @@ -5,7 +5,7 @@ import { applyAction, deserialize } from "$app/forms"; import Spinner from "$comp/Spinner.svelte"; import Pin from "$comp/Pin.svelte"; - import { loading, t } from "$lib/translations"; + import { loading, locale, setLocale, t } from "$lib/translations"; import { fd, fail, auth, post, sleep, warning, success } from "$lib/utils"; import { avatar, banner, signer, password, pin, save } from "$lib/store"; import { upload } from "$lib/upload"; @@ -238,7 +238,9 @@ console.log("Failed to save re-wrapped encryptedKeys", e); } } + const currentLocale = $locale; await invalidateAll(); + if (currentLocale !== $locale) await setLocale(currentLocale); if (pw) $password = pw; } diff --git a/src/routes/(static)/+layout.svelte b/src/routes/(static)/+layout.svelte index 9c7f5e5e..b204cd0e 100644 --- a/src/routes/(static)/+layout.svelte +++ b/src/routes/(static)/+layout.svelte @@ -4,6 +4,7 @@ import Footer from "$comp/Footer.svelte"; import LandingHeader from "$comp/LandingHeader.svelte"; import { theme as themeStore } from "$lib/store"; + import { page } from "$app/stores"; let { data, children } = $props(); let user = $derived(data.user); @@ -11,6 +12,8 @@ $effect(() => { theme = $themeStore; }); + + let hideFooter = $derived($page.url.pathname.startsWith("/login") || $page.url.pathname.startsWith("/register")); </script> <SvelteToast options={{ reversed: true, intro: { y: 192 } }} /> @@ -19,4 +22,6 @@ <main class="container flex px-4 md:px-40 mx-auto min-h-[600px]" data-theme={theme}> {@render children?.()} </main> -<Footer /> +{#if !hideFooter} + <Footer /> +{/if} diff --git a/src/routes/(static)/login/+page.svelte b/src/routes/(static)/login/+page.svelte index 96a03ef5..7a7b06ed 100644 --- a/src/routes/(static)/login/+page.svelte +++ b/src/routes/(static)/login/+page.svelte @@ -30,7 +30,9 @@ password.set(undefined); pin?.set(undefined); signer.set(undefined); + const installDismissed = localStorage.getItem("installDismissed"); localStorage.clear(); + if (installDismissed) localStorage.setItem("installDismissed", installDismissed); sessionStorage.clear(); }, 50); } diff --git a/src/routes/(static)/map/add/+page.svelte b/src/routes/(static)/map/add/+page.svelte new file mode 100644 index 00000000..f2052e28 --- /dev/null +++ b/src/routes/(static)/map/add/+page.svelte @@ -0,0 +1,64 @@ +<script lang="ts"> + import { t } from "$lib/translations"; +</script> + +<div class="max-w-2xl mx-auto py-10 mb-20"> + <h1 class="text-3xl font-bold mb-2">{$t("mapAdd.header")}</h1> + <p class="text-secondary text-lg mb-8"> + {$t("mapAdd.description")} + </p> + + <div class="space-y-8"> + <div class="flex gap-4"> + <div class="flex-shrink-0 w-10 h-10 rounded-full bg-primary text-white flex items-center justify-center font-bold text-lg">1</div> + <div> + <h2 class="text-xl font-semibold mb-1">{$t("mapAdd.step1.header")}</h2> + <p class="text-secondary"> + {$t("mapAdd.step1.before")} <a href="https://www.openstreetmap.org" target="_blank" rel="noopener" class="text-base-content underline"> + {$t("mapAdd.step1.linkText")}</a> {$t("mapAdd.step1.after")} + </p> + </div> + </div> + + <div class="flex gap-4"> + <div class="flex-shrink-0 w-10 h-10 rounded-full bg-primary text-white flex items-center justify-center font-bold text-lg">2</div> + <div> + <h2 class="text-xl font-semibold mb-1">{$t("mapAdd.step2.header")}</h2> + <p class="text-secondary"> + {$t("mapAdd.step2.before")} <strong>{$t("mapAdd.step2.edit")}</strong>, {$t("mapAdd.step2.middle")} <strong>{$t("mapAdd.step2.point")}</strong> {$t("mapAdd.step2.after")} + </p> + </div> + </div> + + <div class="flex gap-4"> + <div class="flex-shrink-0 w-10 h-10 rounded-full bg-primary text-white flex items-center justify-center font-bold text-lg">3</div> + <div> + <h2 class="text-xl font-semibold mb-1">{$t("mapAdd.step3.header")}</h2> + <p class="text-secondary mb-3"> + {$t("mapAdd.step3.description")} + </p> + <div class="bg-neutral text-white rounded-lg p-4 font-mono text-sm space-y-2"> + <div><span class="font-bold">currency:XBT</span> = <span class="font-bold">yes</span></div> + <div><span class="font-bold">payment:coinos</span> = <span class="font-bold">yes</span></div> + </div> + </div> + </div> + + <div class="flex gap-4"> + <div class="flex-shrink-0 w-10 h-10 rounded-full bg-primary text-white flex items-center justify-center font-bold text-lg">4</div> + <div> + <h2 class="text-xl font-semibold mb-1">{$t("mapAdd.step4.header")}</h2> + <p class="text-secondary"> + {$t("mapAdd.step4.before")} <strong>{$t("mapAdd.step4.save")}</strong> {$t("mapAdd.step4.after")} + </p> + </div> + </div> + </div> + + <div class="mt-10 flex justify-center"> + <a href="/map" class="btn btn-primary !w-auto !rounded-full px-8"> + <iconify-icon noobserver icon="ph:arrow-left-bold" width="20"></iconify-icon> + {$t("mapAdd.backToMap")} + </a> + </div> +</div> diff --git a/src/routes/(static)/register/+page.svelte b/src/routes/(static)/register/+page.svelte index 3441b95c..8645356a 100644 --- a/src/routes/(static)/register/+page.svelte +++ b/src/routes/(static)/register/+page.svelte @@ -1,11 +1,14 @@ <script lang="ts"> import { goto } from "$app/navigation"; import { page } from "$app/stores"; + import { browser } from "$app/environment"; import punks from "$lib/punks"; import { avatar } from "$lib/store"; import { focus } from "$lib/utils"; import { t } from "$lib/translations"; - import { NumberDictionary, uniqueNamesGenerator, animals } from "unique-names-generator"; + + + let isMobile = $derived(browser && /Android|iPhone|iPad|iPod/i.test(navigator.userAgent)); let { data }: any = $props(); @@ -20,21 +23,12 @@ } }; - let refresh = async (e: any) => { - e.preventDefault(); - cleared = false; - - username = uniqueNamesGenerator({ - dictionaries: [animals, NumberDictionary.generate({ min: 10, max: 99 })], - length: 2, - separator: "", - }); - }; - let avatarInput: HTMLInputElement = $state() as any; + let cameraInput: HTMLInputElement = $state() as any; + let galleryInput: HTMLInputElement = $state() as any; + let showUploadModal = $state(false); let decr = () => (index = index <= 0 ? 63 : index - 1); let incr = () => (index = index >= 63 ? 0 : index + 1); - let selectAvatar = () => avatarInput.click(); let progress: any; let handleFile = async ({ target }: { target: HTMLInputElement }) => { @@ -44,6 +38,7 @@ if (file.size > 10000000) return; $avatar = { file, type, progress }; + showUploadModal = false; var reader = new FileReader(); reader.onload = async (e: any) => { @@ -55,16 +50,24 @@ let src: string = $derived(`/api/public/${punks[index]}.webp`); - let continueToAuth = () => { - let name = (username || "").replace(/\s*/g, ""); + let error = $state(""); + let continueToAuth = async () => { + let name = (username || "").replace(/\s/g, "").toLowerCase(); if (!name) return; - goto(`/register/auth?username=${encodeURIComponent(name)}&index=${index}`); + error = ""; + let r = await fetch(`/api/users/${name}`); + if (r.ok) { + error = `Username ${name} is taken`; + } else { + goto(`/register/auth?username=${encodeURIComponent(name)}&index=${index}`); + } }; </script> <div class="mx-auto md:shadow-xl rounded-3xl max-w-xl w-full md:w-[480px] md:p-8 space-y-5 mb-20"> <h1 class="text-2xl font-bold text-center">{$t("login.createAccount")}</h1> - <input type="file" accept="image/*" class="hidden!" bind:this={avatarInput} onchange={(e: any) => handleFile(e)} /> + <input type="file" accept="image/*" capture="user" class="hidden!" bind:this={cameraInput} onchange={(e: any) => handleFile(e)} /> + <input type="file" accept="image/*" class="hidden!" bind:this={galleryInput} onchange={(e: any) => handleFile(e)} /> <div class="relative"> <button @@ -74,7 +77,7 @@ > <iconify-icon noobserver icon="ph:caret-left-bold" width="32"></iconify-icon> </button> - <button class="block relative w-32 mx-auto" onclick={selectAvatar}> + <button class="block relative w-32 mx-auto" onclick={() => isMobile ? (showUploadModal = true) : galleryInput.click()}> <div class="w-32 h-32 rounded-full border-4 border-white overflow-hidden flex mx-auto relative" > @@ -84,9 +87,8 @@ alt={username} /> </div> - <div class="absolute bg-base-100 rounded-full px-3 py-1 mx-auto -right-6 -bottom-2 z-10 flex items-center gap-1 text-base"> - <iconify-icon noobserver icon="ph:camera-bold" width="24"></iconify-icon> - Upload + <div class="absolute bg-base-100 rounded-full p-2 -right-2 -bottom-2 z-10"> + <iconify-icon noobserver icon="ph:folder-bold" width="24"></iconify-icon> </div> </button> <button @@ -98,6 +100,10 @@ </button> </div> + {#if error} + <div class="text-red-600 text-center">{error}</div> + {/if} + <div class="space-y-3"> <label for="username" class="input flex items-center gap-2 w-full pr-0! overflow-hidden"> <input @@ -109,17 +115,12 @@ bind:value={username} onfocus={clear} autocapitalize="none" - placeholder={$t("login.username")} + placeholder="Your username" onkeydown={(e: KeyboardEvent) => e.key === "Enter" && continueToAuth()} /> - <span class="bg-base-300 whitespace-nowrap select-none self-stretch flex items-center px-3">@coinos.io</span> + <span class="at-suffix font-bold whitespace-nowrap select-none self-stretch flex items-center px-3">@coinos.io</span> </label> - <button type="button" class="btn gap-2" onclick={refresh}> - <iconify-icon noobserver icon="ph:dice-three-bold" width="32"></iconify-icon> - Random username - </button> - <button class="btn btn-accent" onclick={continueToAuth}> Continue </button> @@ -135,3 +136,42 @@ </p> </div> </div> + +{#if showUploadModal} + <div + class="fixed inset-0 bg-black/50 z-50 flex items-start justify-center pt-32" + role="button" + tabindex="0" + onclick={() => (showUploadModal = false)} + onkeydown={(e) => e.key === "Escape" && (showUploadModal = false)} + > + <!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions --> + <div class="bg-base-100 rounded-2xl p-6 w-full max-w-sm space-y-3" role="none" onclick={(e) => e.stopPropagation()}> + <h2 class="text-lg font-semibold text-center">Upload photo</h2> + {#if isMobile} + <button class="btn w-full gap-2" onclick={() => cameraInput.click()}> + <iconify-icon noobserver icon="ph:camera-bold" width="24"></iconify-icon> + Take photo + </button> + {/if} + <button class="btn w-full gap-2" onclick={() => galleryInput.click()}> + <iconify-icon noobserver icon="ph:images-bold" width="24"></iconify-icon> + Choose from gallery + </button> + <button class="btn w-full" onclick={() => (showUploadModal = false)}> + Cancel + </button> + </div> + </div> +{/if} + +<style> + .at-suffix { + background: black; + color: white; + } + :global([data-theme="black"]) .at-suffix { + background: rgba(255, 255, 255, 0.2); + color: white; + } +</style> diff --git a/src/routes/(static)/register/auth/+page.svelte b/src/routes/(static)/register/auth/+page.svelte index ad5d6e54..5809ef4b 100644 --- a/src/routes/(static)/register/auth/+page.svelte +++ b/src/routes/(static)/register/auth/+page.svelte @@ -50,7 +50,9 @@ password.set(undefined); pin.set(undefined); signer.set(undefined); + const installDismissed = localStorage.getItem("installDismissed"); localStorage.clear(); + if (installDismissed) localStorage.setItem("installDismissed", installDismissed); sessionStorage.clear(); }, 50); } @@ -322,7 +324,7 @@ <div class="w-24 h-24 rounded-full overflow-hidden"> <img {src} class="w-full h-full object-cover" alt={username} /> </div> - <span class="text-xl font-medium">{username}</span> + <span class="text-xl font-bold">{username}</span> </div> {#if form?.error || form?.message} |
