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,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
export let data
|
||||
let { data, children } = $props();
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -16,4 +16,4 @@
|
||||
/>
|
||||
{/if}
|
||||
</svelte:head>
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy';
|
||||
|
||||
import { navigating, page } from '$app/stores'
|
||||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
@@ -31,11 +33,14 @@
|
||||
import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
export let data
|
||||
let { data = $bindable() } = $props();
|
||||
|
||||
$: community = data.community.community_view
|
||||
let community;
|
||||
run(() => {
|
||||
community = data.community.community_view
|
||||
});
|
||||
|
||||
let sidebar: boolean = false
|
||||
let sidebar: boolean = $state(false)
|
||||
|
||||
onMount(() => {
|
||||
if (browser)
|
||||
@@ -63,7 +68,9 @@
|
||||
|
||||
{#if sidebar}
|
||||
<Modal bind:open={sidebar}>
|
||||
<span slot="title">About</span>
|
||||
{#snippet title()}
|
||||
<span >About</span>
|
||||
{/snippet}
|
||||
<div>
|
||||
<CommunityCard
|
||||
bind:community_view={community}
|
||||
@@ -83,7 +90,9 @@
|
||||
counts={community.counts}
|
||||
class="w-full relative"
|
||||
/>
|
||||
<Sort selected={data.sort} slot="extended" />
|
||||
{#snippet extended()}
|
||||
<Sort selected={data.sort} />
|
||||
{/snippet}
|
||||
</Header>
|
||||
{#if community.blocked}
|
||||
<Placeholder
|
||||
@@ -92,13 +101,15 @@
|
||||
description="You've blocked this community."
|
||||
>
|
||||
<Button href="/profile/blocks">
|
||||
<Icon src={ArrowRight} size="16" mini slot="suffix" />
|
||||
{#snippet suffix()}
|
||||
<Icon src={ArrowRight} size="16" mini />
|
||||
{/snippet}
|
||||
Blocked Communities
|
||||
</Button>
|
||||
</Placeholder>
|
||||
{:else}
|
||||
<svelte:component
|
||||
this={browser ? VirtualFeed : PostFeed}
|
||||
{@const SvelteComponent = browser ? VirtualFeed : PostFeed}
|
||||
<SvelteComponent
|
||||
posts={data.posts.posts}
|
||||
bind:feedData={data}
|
||||
feedId="community"
|
||||
|
||||
@@ -8,12 +8,17 @@
|
||||
import { fullCommunityName } from '$lib/util.js'
|
||||
import type { PageData } from './$types.js'
|
||||
|
||||
export let data: PageData
|
||||
interface Props {
|
||||
data: PageData;
|
||||
children?: import('svelte').Snippet;
|
||||
}
|
||||
|
||||
$: communityUrl = `/c/${fullCommunityName(
|
||||
let { data, children }: Props = $props();
|
||||
|
||||
let communityUrl = $derived(`/c/${fullCommunityName(
|
||||
data.community.community_view.community.name,
|
||||
data.community.community_view.community.actor_id
|
||||
)}`
|
||||
)}`)
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4 h-full">
|
||||
@@ -34,5 +39,5 @@
|
||||
]}
|
||||
></Tabs>
|
||||
</div>
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
</div>
|
||||
@@ -3,16 +3,18 @@
|
||||
import CommunityTitle from '$lib/components/lemmy/community/CommunityTitle.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
export let data
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<Header pageHeader>
|
||||
<span>Settings</span>
|
||||
<CommunityTitle
|
||||
slot="extended"
|
||||
community={data.community.community_view.community}
|
||||
/>
|
||||
{#snippet extended()}
|
||||
<CommunityTitle
|
||||
|
||||
community={data.community.community_view.community}
|
||||
/>
|
||||
{/snippet}
|
||||
</Header>
|
||||
<CommunityForm
|
||||
edit={data.community.community_view.community.id}
|
||||
@@ -29,6 +31,8 @@
|
||||
submitting: false,
|
||||
}}
|
||||
>
|
||||
<svelte:fragment slot="formtitle">{''}</svelte:fragment>
|
||||
{#snippet formtitle()}
|
||||
{''}
|
||||
{/snippet}
|
||||
</CommunityForm>
|
||||
</div>
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import EditableList from '$lib/components/ui/list/EditableList.svelte'
|
||||
@@ -12,12 +14,16 @@
|
||||
import { t } from '$lib/translations.js'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
export let data: PageData
|
||||
interface Props {
|
||||
data: PageData;
|
||||
}
|
||||
|
||||
let formData = {
|
||||
let { data = $bindable() }: Props = $props();
|
||||
|
||||
let formData = $state({
|
||||
newModerator: '',
|
||||
addingModerator: false,
|
||||
}
|
||||
})
|
||||
|
||||
async function addModerator() {
|
||||
if (!$profile?.jwt) return
|
||||
@@ -103,7 +109,7 @@
|
||||
|
||||
<Header pageHeader>Moderators</Header>
|
||||
<EditableList
|
||||
let:action
|
||||
|
||||
on:action={(e) => {
|
||||
toast({
|
||||
content: `Are you sure you want to remove ${e.detail.name} as a moderator?`,
|
||||
@@ -111,31 +117,33 @@
|
||||
})
|
||||
}}
|
||||
>
|
||||
{#each data.community.moderators as moderator (moderator.moderator.id)}
|
||||
<div
|
||||
class="py-4 flex items-center gap-2 justify-between"
|
||||
animate:flip={{ duration: 300 }}
|
||||
>
|
||||
<div class="flex gap-2 items-center">
|
||||
<Avatar
|
||||
width={28}
|
||||
url={moderator.moderator.avatar}
|
||||
alt={moderator.moderator.name}
|
||||
/>
|
||||
<div class="flex flex-col gap-0">
|
||||
<UserLink user={moderator.moderator} showInstance={false} />
|
||||
<span class="text-xs text-slate-600 dark:text-zinc-400">
|
||||
{new URL(moderator.moderator.actor_id).hostname}
|
||||
</span>
|
||||
{#snippet children({ action })}
|
||||
{#each data.community.moderators as moderator (moderator.moderator.id)}
|
||||
<div
|
||||
class="py-4 flex items-center gap-2 justify-between"
|
||||
animate:flip={{ duration: 300 }}
|
||||
>
|
||||
<div class="flex gap-2 items-center">
|
||||
<Avatar
|
||||
width={28}
|
||||
url={moderator.moderator.avatar}
|
||||
alt={moderator.moderator.name}
|
||||
/>
|
||||
<div class="flex flex-col gap-0">
|
||||
<UserLink user={moderator.moderator} showInstance={false} />
|
||||
<span class="text-xs text-slate-600 dark:text-zinc-400">
|
||||
{new URL(moderator.moderator.actor_id).hostname}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<Button size="square-md" on:click={() => action(moderator.moderator)}>
|
||||
<Icon src={Trash} mini size="16" />
|
||||
</Button>
|
||||
</div>
|
||||
<Button size="square-md" on:click={() => action(moderator.moderator)}>
|
||||
<Icon src={Trash} mini size="16" />
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
{/each}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
<form on:submit|preventDefault={addModerator} class="mt-auto flex gap-2 w-full">
|
||||
<form onsubmit={preventDefault(addModerator)} class="mt-auto flex gap-2 w-full">
|
||||
<TextInput
|
||||
bind:value={formData.newModerator}
|
||||
class="w-full"
|
||||
@@ -149,6 +157,8 @@
|
||||
color="primary"
|
||||
submit
|
||||
>
|
||||
<Icon slot="prefix" src={Plus} micro size="16" /> Add moderator
|
||||
{#snippet prefix()}
|
||||
<Icon src={Plus} micro size="16" />
|
||||
{/snippet} Add moderator
|
||||
</Button>
|
||||
</form>
|
||||
Reference in new issue
Block a user