migrate: convert most components to svelte 5
This commit is contained in:
1 parent
d670f39f0a
commit
10ef4123da
225 files changed
+5441
-3341
No files matched your search
@@ -1 +1,11 @@
|
||||
<slot />
|
||||
<script>
|
||||
/**
|
||||
* @typedef {Object} Props
|
||||
* @property {import('svelte').Snippet} [children]
|
||||
*/
|
||||
|
||||
/** @type {Props} */
|
||||
let { children } = $props();
|
||||
</script>
|
||||
|
||||
{@render children?.()}
|
||||
@@ -1,5 +1,15 @@
|
||||
<script>
|
||||
/**
|
||||
* @typedef {Object} Props
|
||||
* @property {import('svelte').Snippet} [children]
|
||||
*/
|
||||
|
||||
/** @type {Props} */
|
||||
let { children } = $props();
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800 [&>*]:py-3 first:p-0 last:py-0"
|
||||
>
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
</div>
|
||||
@@ -22,12 +22,17 @@
|
||||
import UserAutocomplete from '$lib/components/lemmy/user/UserAutocomplete.svelte'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
|
||||
// sveltekit doesn't feel like making types work right now
|
||||
export let data: PageData & {
|
||||
|
||||
interface Props {
|
||||
// sveltekit doesn't feel like making types work right now
|
||||
data: PageData & {
|
||||
person_blocks: PersonBlockView[]
|
||||
community_blocks: CommunityBlockView[]
|
||||
};
|
||||
}
|
||||
|
||||
let { data = $bindable() }: Props = $props();
|
||||
|
||||
async function unblockUser(item: PersonBlockView) {
|
||||
if (!$profile?.jwt) return
|
||||
|
||||
@@ -86,77 +91,89 @@
|
||||
{#if data.my_user?.instance_blocks && (data.my_user?.instance_blocks?.length ?? 0) > 0}
|
||||
<div>
|
||||
<SectionTitle>{$t('content.instances')}</SectionTitle>
|
||||
<EditableList let:action on:action={(i) => unblockInstances(i.detail)}>
|
||||
{#each data.my_user?.instance_blocks as block (block.instance.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-4"
|
||||
animate:flip={{ duration: 250 }}
|
||||
out:slide|local={{ axis: 'y' }}
|
||||
>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
on:click={() => action(block)}
|
||||
<EditableList on:action={(i) => unblockInstances(i.detail)}>
|
||||
{#snippet children({ action })}
|
||||
{#each data.my_user?.instance_blocks as block (block.instance.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-4"
|
||||
animate:flip={{ duration: 250 }}
|
||||
out:slide|local={{ axis: 'y' }}
|
||||
>
|
||||
<Icon src={XMark} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
<Entity
|
||||
icon={block.site?.icon}
|
||||
name={block.site?.name ?? block.instance.domain}
|
||||
label={block.instance.domain}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
</EditableList>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
on:click={() => action(block)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<Entity
|
||||
icon={block.site?.icon}
|
||||
name={block.site?.name ?? block.instance.domain}
|
||||
label={block.instance.domain}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
</div>
|
||||
{/if}
|
||||
{#if data.community_blocks?.length > 0}
|
||||
<div>
|
||||
<SectionTitle>{$t('content.communities')}</SectionTitle>
|
||||
<EditableList let:action on:action={(i) => unblockCommunity(i.detail)}>
|
||||
{#each data.community_blocks as block (block.community.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-2"
|
||||
animate:flip={{ duration: 250 }}
|
||||
out:slide|global={{ axis: 'y', easing: expoOut, duration: 300 }}
|
||||
>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
on:click={() => action(block)}
|
||||
<EditableList on:action={(i) => unblockCommunity(i.detail)}>
|
||||
{#snippet children({ action })}
|
||||
{#each data.community_blocks as block (block.community.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-2"
|
||||
animate:flip={{ duration: 250 }}
|
||||
out:slide|global={{ axis: 'y', easing: expoOut, duration: 300 }}
|
||||
>
|
||||
<Icon src={XMark} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
<CommunityLink community={block.community} avatar />
|
||||
</div>
|
||||
{/each}
|
||||
</EditableList>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
on:click={() => action(block)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<CommunityLink community={block.community} avatar />
|
||||
</div>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
</div>
|
||||
{/if}
|
||||
{#if data.person_blocks?.length > 0}
|
||||
<div>
|
||||
<SectionTitle>{$t('content.users')}</SectionTitle>
|
||||
<EditableList let:action on:action={(i) => unblockUser(i.detail)}>
|
||||
{#each data.person_blocks as block (block.target.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-2"
|
||||
animate:flip={{ duration: 250 }}
|
||||
out:slide|global={{ axis: 'y', easing: expoOut, duration: 300 }}
|
||||
>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
on:click={() => action(block)}
|
||||
<EditableList on:action={(i) => unblockUser(i.detail)}>
|
||||
{#snippet children({ action })}
|
||||
{#each data.person_blocks as block (block.target.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-2"
|
||||
animate:flip={{ duration: 250 }}
|
||||
out:slide|global={{ axis: 'y', easing: expoOut, duration: 300 }}
|
||||
>
|
||||
<Icon src={XMark} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
<UserLink user={block.target} avatar badges />
|
||||
</div>
|
||||
{/each}
|
||||
</EditableList>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
on:click={() => action(block)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<UserLink user={block.target} avatar badges />
|
||||
</div>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
|
||||
@@ -5,6 +5,13 @@
|
||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { page } from '$app/stores'
|
||||
/**
|
||||
* @typedef {Object} Props
|
||||
* @property {import('svelte').Snippet} [children]
|
||||
*/
|
||||
|
||||
/** @type {Props} */
|
||||
let { children } = $props();
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@@ -47,6 +54,6 @@
|
||||
{/each}
|
||||
</nav>
|
||||
<div class="flex-[3] max-w-full w-full min-w-0">
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
</div>
|
||||
</div>
|
||||
@@ -10,7 +10,7 @@
|
||||
UserGroup,
|
||||
} from 'svelte-hero-icons'
|
||||
|
||||
export let data
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { run, preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
@@ -8,14 +10,17 @@
|
||||
import { Button, Material, TextInput, toast } from 'mono-svelte'
|
||||
import { ClipboardDocument, Icon } from 'svelte-hero-icons'
|
||||
|
||||
export let data
|
||||
let { data } = $props();
|
||||
|
||||
// @ts-ignore
|
||||
let totpLink: string | undefined = undefined
|
||||
$: totpEnabled =
|
||||
data.my_user?.local_user_view.local_user.totp_2fa_enabled ?? totpLink
|
||||
let totpLink: string | undefined = $state(undefined)
|
||||
let totpEnabled;
|
||||
run(() => {
|
||||
totpEnabled =
|
||||
data.my_user?.local_user_view.local_user.totp_2fa_enabled ?? totpLink
|
||||
});
|
||||
|
||||
let verify_totp = ''
|
||||
let verify_totp = $state('')
|
||||
|
||||
async function twofa(enabled: boolean, update: boolean = false) {
|
||||
try {
|
||||
@@ -59,17 +64,19 @@
|
||||
value={totpLink}
|
||||
label={$t('form.profile.2fa.totp')}
|
||||
>
|
||||
<button
|
||||
slot="suffix"
|
||||
class="contents"
|
||||
on:click={() => {
|
||||
{#snippet suffix()}
|
||||
<button
|
||||
|
||||
class="contents"
|
||||
onclick={() => {
|
||||
if (!totpLink) return
|
||||
navigator.clipboard?.writeText(totpLink)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}}
|
||||
>
|
||||
<Icon src={ClipboardDocument} size="20" mini />
|
||||
</button>
|
||||
>
|
||||
<Icon src={ClipboardDocument} size="20" mini />
|
||||
</button>
|
||||
{/snippet}
|
||||
<span class="font-normal text-xs">
|
||||
{$t('form.profile.2fa.paste')}
|
||||
</span>
|
||||
@@ -77,7 +84,7 @@
|
||||
{/if}
|
||||
<form
|
||||
class="flex flex-col gap-2 w-full"
|
||||
on:submit|preventDefault={() => {}}
|
||||
onsubmit={preventDefault(() => {})}
|
||||
>
|
||||
<TextInput
|
||||
bind:value={verify_totp}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { deleteProfile, profile, setUser } from '$lib/auth'
|
||||
import { client } from '$lib/lemmy'
|
||||
import { instance as currentInstance } from '$lib/instance'
|
||||
@@ -6,10 +8,10 @@
|
||||
import { Button, TextInput, toast } from 'mono-svelte'
|
||||
import { errorMessage } from '$lib/lemmy/error'
|
||||
|
||||
let oldPassword = '',
|
||||
newPassword = '',
|
||||
newPasswordVerify = ''
|
||||
let loading = false
|
||||
let oldPassword = $state(''),
|
||||
newPassword = $state(''),
|
||||
newPasswordVerify = $state('')
|
||||
let loading = $state(false)
|
||||
|
||||
async function changePassword() {
|
||||
try {
|
||||
@@ -42,7 +44,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<form on:submit|preventDefault={changePassword} class="flex flex-col gap-4">
|
||||
<form onsubmit={preventDefault(changePassword)} class="flex flex-col gap-4">
|
||||
<TextInput
|
||||
bind:value={oldPassword}
|
||||
label={$t('form.profile.currentPassword')}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
toast,
|
||||
} from 'mono-svelte'
|
||||
|
||||
let deletion = {
|
||||
let deletion = $state({
|
||||
modal: false,
|
||||
password: '',
|
||||
deleteContent: false,
|
||||
}
|
||||
})
|
||||
|
||||
async function deleteAccount(level: number) {
|
||||
switch (level) {
|
||||
@@ -101,7 +101,9 @@
|
||||
action="Submit"
|
||||
on:action={() => deleteAccount(4)}
|
||||
>
|
||||
<span slot="title">{$t('form.profile.deleteAccount.label')}</span>
|
||||
{#snippet title()}
|
||||
<span >{$t('form.profile.deleteAccount.label')}</span>
|
||||
{/snippet}
|
||||
<TextInput
|
||||
label={$t('form.password')}
|
||||
type="password"
|
||||
@@ -109,9 +111,11 @@
|
||||
/>
|
||||
<Checkbox bind:checked={deletion.deleteContent}>
|
||||
{$t('form.profile.deleteAccount.deleteContent')}
|
||||
<span slot="description">
|
||||
{$t('form.profile.deleteAccount.warning')}
|
||||
</span>
|
||||
{#snippet description()}
|
||||
<span >
|
||||
{$t('form.profile.deleteAccount.warning')}
|
||||
</span>
|
||||
{/snippet}
|
||||
</Checkbox>
|
||||
</Modal>
|
||||
{/if}
|
||||
@@ -130,9 +134,11 @@
|
||||
</p>
|
||||
<Switch bind:checked={deletion.deleteContent}>
|
||||
{$t('form.profile.deleteAccount.deleteContent')}
|
||||
<span slot="description">
|
||||
{$t('form.profile.deleteAccount.warning')}
|
||||
</span>
|
||||
{#snippet description()}
|
||||
<span >
|
||||
{$t('form.profile.deleteAccount.warning')}
|
||||
</span>
|
||||
{/snippet}
|
||||
</Switch>
|
||||
<Button size="lg" color="danger" on:click={() => deleteAccount(3)}>
|
||||
{$t('routes.profile.delete.title')}
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
import { UAParser } from 'ua-parser-js'
|
||||
|
||||
export let data
|
||||
let { data } = $props();
|
||||
|
||||
let checked: {
|
||||
[token: string]: boolean
|
||||
} = {}
|
||||
} = $state({})
|
||||
</script>
|
||||
|
||||
<Material
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { profile, profileData, setUserID } from '$lib/auth.js'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { ImageInput, Material, removeToast, toast } from 'mono-svelte'
|
||||
@@ -9,16 +11,21 @@
|
||||
import { t } from '$lib/translations.js'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
export let inline: boolean = false
|
||||
export let data
|
||||
|
||||
let formData: Omit<SaveUserSettings, 'auth'> | undefined = {
|
||||
...data.my_user?.local_user_view?.local_user,
|
||||
...data.my_user?.local_user_view?.person,
|
||||
interface Props {
|
||||
inline?: boolean;
|
||||
data: any;
|
||||
children?: import('svelte').Snippet;
|
||||
}
|
||||
|
||||
let profileImage: FileList | undefined
|
||||
let bannerImage: FileList | undefined
|
||||
let { inline = false, data, children }: Props = $props();
|
||||
|
||||
let formData: Omit<SaveUserSettings, 'auth'> | undefined = $state({
|
||||
...data.my_user?.local_user_view?.local_user,
|
||||
...data.my_user?.local_user_view?.person,
|
||||
})
|
||||
|
||||
let profileImage: FileList | undefined = $state()
|
||||
let bannerImage: FileList | undefined = $state()
|
||||
|
||||
async function save() {
|
||||
if (!formData || !$profile?.jwt) return
|
||||
@@ -53,14 +60,14 @@
|
||||
loading = false
|
||||
}
|
||||
|
||||
let loading = false
|
||||
let loading = $state(false)
|
||||
</script>
|
||||
|
||||
<form class="flex flex-col gap-4 h-full" on:submit|preventDefault={save}>
|
||||
<form class="flex flex-col gap-4 h-full" onsubmit={preventDefault(save)}>
|
||||
{#if !inline}
|
||||
<Header pageHeader>{$t('routes.profile.settings')}</Header>
|
||||
{/if}
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
{#if data.my_user?.local_user_view?.local_user && formData}
|
||||
<TextInput label={$t('form.profile.email')} bind:value={formData.email} />
|
||||
<TextInput
|
||||
|
||||
Reference in new issue
Block a user