feat: update signup page
This commit is contained in:
1 parent
a12f153dc1
commit
7f9ab04c11
19 files changed
+236
-84
No files matched your search
@@ -94,10 +94,10 @@
|
||||
<Sidebar />
|
||||
<div
|
||||
class="w-full min-w-0 border-t sm:border-l border-slate-200 dark:border-zinc-900
|
||||
sm:rounded-xl bg-slate-25 dark:bg-zinc-950"
|
||||
sm:rounded-xl bg-slate-25 dark:bg-zinc-950 min-h-full"
|
||||
>
|
||||
<main
|
||||
class="p-3 sm:p-6 min-w-0 w-full flex-[3] sm:rounded-tl-lg mx-auto
|
||||
class="p-3 sm:p-6 min-w-0 w-full flex-[3] sm:rounded-tl-lg mx-auto flex flex-col min-h-full
|
||||
"
|
||||
class:max-w-6xl={$userSettings.newWidth}
|
||||
id="main"
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
ChevronUp,
|
||||
EllipsisHorizontal,
|
||||
Icon,
|
||||
Identification,
|
||||
PaintBrush,
|
||||
Plus,
|
||||
Trash,
|
||||
@@ -92,18 +93,25 @@
|
||||
{/if}
|
||||
|
||||
{#if $profileData.profiles.length == 0}
|
||||
<div class="h-full flex items-center justify-center">
|
||||
<div class="h-max flex items-center justify-center my-auto">
|
||||
<div
|
||||
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center py-8 gap-4"
|
||||
class="flex flex-col justify-center items-center py-8 gap-4
|
||||
my-auto"
|
||||
>
|
||||
<div class="flex flex-col items-center">
|
||||
<Icon src={ArrowLeftOnRectangle} size="48" solid />
|
||||
<h1 class="font-bold text-3xl">No accounts</h1>
|
||||
</div>
|
||||
<Button href="/login" size="lg">
|
||||
<Icon slot="prefix" src={ArrowLeftOnRectangle} size="16" mini />
|
||||
Log in
|
||||
</Button>
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<Button href="/login" size="lg">
|
||||
<Icon slot="prefix" src={ArrowLeftOnRectangle} size="16" mini />
|
||||
Log in
|
||||
</Button>
|
||||
<Button href="/signup" size="lg">
|
||||
<Icon slot="prefix" src={Identification} size="16" mini />
|
||||
Sign up
|
||||
</Button>
|
||||
</div>
|
||||
<div class="flex flex-row font-normal gap-2">
|
||||
<TextInput
|
||||
label="Guest instance"
|
||||
|
||||
@@ -95,15 +95,13 @@
|
||||
<option value="messages">Messages</option>
|
||||
</Select>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4 list-none my-4 flex-1">
|
||||
<div class="flex flex-col gap-4 list-none my-4 flex-1 h-full">
|
||||
{#if !data.data || (data.data?.length ?? 0) == 0}
|
||||
<div class="mt-auto">
|
||||
<Placeholder
|
||||
icon={Inbox}
|
||||
title="No new notifications"
|
||||
description="Messages, replies, and mentions will appear here."
|
||||
/>
|
||||
</div>
|
||||
<Placeholder
|
||||
icon={Inbox}
|
||||
title="No new notifications"
|
||||
description="Messages, replies, and mentions will appear here."
|
||||
/>
|
||||
{:else}
|
||||
{#each data.data as item}
|
||||
<div in:fly={{ duration: 500, y: -6, opacity: 0 }}>
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import { profile, profileData, setUserID } from '$lib/auth.js'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { ImageInput, Material, removeToast, toast } from 'mono-svelte'
|
||||
import { getClient, uploadImage } from '$lib/lemmy.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { SaveUserSettings } from 'lemmy-js-client'
|
||||
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
|
||||
import { uploadImage } from '$lib/util.js'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -22,7 +23,9 @@
|
||||
loading = true
|
||||
|
||||
try {
|
||||
let pfp = profileImage ? await uploadImage(profileImage[0]) : undefined
|
||||
let pfp = profileImage
|
||||
? await uploadImage(profileImage[0], $profile.instance, $profile.jwt)
|
||||
: undefined
|
||||
const res = await getClient().saveUserSettings({
|
||||
auth: $profile.jwt,
|
||||
...formData,
|
||||
|
||||
+115
-12
@@ -1,29 +1,132 @@
|
||||
<script context="module" lang="ts">
|
||||
export interface Instance {
|
||||
baseurl: string
|
||||
name: string
|
||||
desc: string
|
||||
fed: boolean
|
||||
downvotes: boolean
|
||||
icon: string
|
||||
banner: string
|
||||
langs?: string[]
|
||||
tags?: string[]
|
||||
score: number
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { Badge, Material, Spinner, toast } from 'mono-svelte'
|
||||
import { DEFAULT_INSTANCE_URL } from '$lib/instance.js'
|
||||
import { validateInstance } from '$lib/lemmy.js'
|
||||
import { Button, TextInput } from 'mono-svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
|
||||
let instance: string = ''
|
||||
let selectedInstance: string = ''
|
||||
let validating: boolean = false
|
||||
let placeholder = DEFAULT_INSTANCE_URL
|
||||
|
||||
let instances: Instance[] | undefined = undefined
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
const res: Instance[] = (
|
||||
await fetch(`https://data.lemmyverse.net/data/instance.full.json`).then(
|
||||
(r) => r.json()
|
||||
)
|
||||
)
|
||||
.filter((i: Instance) => i.fed)
|
||||
.sort((a: Instance, b: Instance) => b.score - a.score)
|
||||
.slice(0, 100)
|
||||
|
||||
instances = res
|
||||
|
||||
let placeholderIndex = 0
|
||||
setInterval(() => {
|
||||
if (!instances) return
|
||||
if (placeholderIndex >= instances.length) placeholderIndex = 0
|
||||
placeholder = instances?.[placeholderIndex].baseurl
|
||||
placeholderIndex++
|
||||
}, 2000)
|
||||
|
||||
// instances = [
|
||||
// {
|
||||
// banner: '',
|
||||
// baseurl: 'fart.net',
|
||||
// desc: 'a instance',
|
||||
// downvotes: false,
|
||||
// fed: true,
|
||||
// icon: '',
|
||||
// langs: [''],
|
||||
// name: 'fart',
|
||||
// tags: ['okay'],
|
||||
// },
|
||||
// ]
|
||||
} catch (e) {
|
||||
toast({
|
||||
content: 'Failed to fetch available instances.',
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
let heights: number[] = []
|
||||
|
||||
const addHeight = (node: HTMLButtonElement, index: number) => {
|
||||
heights.splice(index, 0, node.clientHeight)
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Sign up | Choose Instance</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="mx-auto max-w-xl flex flex-col gap-4">
|
||||
<h1 class="font-bold text-2xl">Sign Up</h1>
|
||||
<h2 class="font-bold text-xl">Choose an instance</h2>
|
||||
<div class="mx-auto max-w-xl flex flex-col gap-4 my-auto h-max w-full">
|
||||
<h1 class="font-bold text-4xl">Sign Up</h1>
|
||||
<p>Choose an instance that interests you, or type the URL manually.</p>
|
||||
<p>
|
||||
An instance is the server that your account will be hosted on, but you can
|
||||
still access and interact with content from other instances.
|
||||
</p>
|
||||
<Material color="distinct" class="h-64 overflow-auto">
|
||||
<div
|
||||
class="flex flex-col h-full divide-y divide-slate-200 dark:divide-zinc-800"
|
||||
>
|
||||
{#if instances}
|
||||
{#each instances as instance}
|
||||
<button
|
||||
on:click={() => (selectedInstance = instance.baseurl ?? '')}
|
||||
class="flex flex-row gap-2 text-left py-2 first:pt-0 last:pb-0 items-center"
|
||||
>
|
||||
<Avatar
|
||||
width={32}
|
||||
url={instance.icon}
|
||||
alt={instance.name}
|
||||
class="flex-shrink-0"
|
||||
/>
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium text-base">
|
||||
{instance.name}
|
||||
</span>
|
||||
<span>{instance.desc}</span>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
{:else}
|
||||
<div class="mx-auto my-auto self-center justify-self-center">
|
||||
<Spinner width={32} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</Material>
|
||||
<form
|
||||
class="flex flex-col gap-4"
|
||||
on:submit|preventDefault={async () => {
|
||||
if (instance != '') {
|
||||
if (selectedInstance != '') {
|
||||
validating = true
|
||||
|
||||
if (await validateInstance(instance.trim())) {
|
||||
goto(`/signup/${instance}`)
|
||||
if (await validateInstance(selectedInstance.trim())) {
|
||||
goto(`/signup/${selectedInstance}`)
|
||||
} else {
|
||||
toast({
|
||||
content: 'Could not contact that instance URL',
|
||||
@@ -36,12 +139,12 @@
|
||||
}}
|
||||
>
|
||||
<TextInput
|
||||
bind:value={instance}
|
||||
label="Instance URL"
|
||||
bind:value={selectedInstance}
|
||||
label="Choose an instance"
|
||||
required
|
||||
placeholder={DEFAULT_INSTANCE_URL}
|
||||
{placeholder}
|
||||
on:input={() => {
|
||||
instance = instance.toLowerCase().replaceAll(' ', '')
|
||||
selectedInstance = selectedInstance.toLowerCase().replaceAll(' ', '')
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
|
||||
Whitespace-only changes.
@@ -92,7 +92,7 @@
|
||||
</svelte:head>
|
||||
|
||||
<form
|
||||
class="flex flex-col gap-4 max-w-2xl mx-auto h-full"
|
||||
class="flex flex-col gap-4 max-w-2xl mx-auto h-full w-full"
|
||||
on:submit|preventDefault={submit}
|
||||
>
|
||||
<span class="flex gap-4 items-center font-bold text-xl text-center mx-auto">
|
||||
|
||||
Reference in new issue
Block a user