migrate: convert most components to svelte 5

This commit is contained in:
Xylight committed 2024-10-25 19:33:27 -07:00
1 parent d670f39f0a
commit 10ef4123da
225 files changed
+5441 -3341

No files matched your search

+10 -8
View File
@@ -1,4 +1,4 @@
<script context="module" lang="ts">
<script module lang="ts">
export interface Instance {
baseurl: string
name: string
@@ -14,6 +14,8 @@
</script>
<script lang="ts">
import { preventDefault } from 'svelte/legacy';
import { goto } from '$app/navigation'
import { Badge, Material, Spinner, toast } from 'mono-svelte'
import { DEFAULT_INSTANCE_URL } from '$lib/instance.js'
@@ -24,11 +26,11 @@
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let selectedInstance: string = ''
let validating: boolean = false
let placeholder = DEFAULT_INSTANCE_URL
let selectedInstance: string = $state('')
let validating: boolean = $state(false)
let placeholder = $state(DEFAULT_INSTANCE_URL)
let instances: Instance[] | undefined = undefined
let instances: Instance[] | undefined = $state(undefined)
onMount(async () => {
try {
@@ -76,7 +78,7 @@
{#if instances}
{#each instances as instance}
<button
on:click={() => (selectedInstance = instance.baseurl ?? '')}
onclick={() => (selectedInstance = instance.baseurl ?? '')}
class="flex flex-row gap-2 text-left py-2 first:pt-0 last:pb-0 items-center
h-16 max-h-16 min-h-16 overflow-hidden w-full"
>
@@ -109,7 +111,7 @@
</Material>
<form
class="flex flex-col gap-4"
on:submit|preventDefault={async () => {
onsubmit={preventDefault(async () => {
if (selectedInstance != '') {
validating = true
@@ -124,7 +126,7 @@
validating = false
}
}}
})}
>
<TextInput
bind:value={selectedInstance}
+20 -16
View File
@@ -1,4 +1,6 @@
<script lang="ts">
import { run, preventDefault } from 'svelte/legacy';
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { setUser } from '$lib/auth.js'
@@ -23,32 +25,34 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js'
export let data
let { data } = $props();
const instance = $page.params.instance
let captchaRequired = data.site_view.local_site.captcha_enabled
let email: string | undefined = ''
let email: string | undefined = $state('')
$: if (email == '') email = undefined
run(() => {
if (email == '') email = undefined
});
let username = '',
password = '',
passwordVerify = '',
captcha: GetCaptchaResponse | null = null,
verifyCaptcha: string | undefined = undefined,
application: string | undefined = undefined,
submitting: boolean = false,
honeypot: string | undefined = undefined,
nsfw: boolean = false
let username = $state(''),
password = $state(''),
passwordVerify = $state(''),
captcha: GetCaptchaResponse | null = $state(null),
verifyCaptcha: string | undefined = $state(undefined),
application: string | undefined = $state(undefined),
submitting: boolean = $state(false),
honeypot: string | undefined = $state(undefined),
nsfw: boolean = $state(false)
const getCaptcha = async () =>
(captcha = await getClient(instance, fetch).getCaptcha())
$: captchaAudio = captcha?.ok?.wav
let captchaAudio = $derived(captcha?.ok?.wav
? `data:audio/wav;base64,${captcha.ok.wav}`
: ''
: '')
async function submit() {
submitting = true
@@ -115,7 +119,7 @@
<form
class="flex flex-col gap-4 max-w-2xl mx-auto h-full w-full"
on:submit|preventDefault={submit}
onsubmit={preventDefault(submit)}
>
<span class="flex gap-4 items-center font-bold text-xl text-center mx-auto">
{#if data.site_view.site.icon}
@@ -172,7 +176,7 @@
alt="Captcha"
class="w-max"
/>
<audio controls src={captchaAudio} />
<audio controls src={captchaAudio}></audio>
{:else}
<Material
class="flex gap-2 dark:text-yellow-200 text-yellow-800 bg-yellow-500/20"