design: improve instances page
This commit is contained in:
5 files changed
+156
-65
No files matched your search
@@ -4,12 +4,12 @@
|
||||
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
||||
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
||||
import { Material, Option } from 'mono-svelte'
|
||||
@@ -17,7 +17,6 @@
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly } from 'svelte/transition'
|
||||
import SearchBar from '../search/SearchBar.svelte'
|
||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
@@ -44,43 +43,46 @@
|
||||
|
||||
<Header pageHeader class="justify-between">
|
||||
<span>{$t('routes.communities.title')}</span>
|
||||
|
||||
{#snippet extended()}
|
||||
<form method="get" action="/communities" class="contents" bind:this={form}>
|
||||
<SearchBar bind:query={search} />
|
||||
|
||||
<div class="flex flex-row flex-wrap gap-4 mt-4 items-center">
|
||||
<Location
|
||||
name="type"
|
||||
selected={data.type}
|
||||
onchange={() => form?.requestSubmit()}
|
||||
>
|
||||
{#if !LINKED_INSTANCE_URL}
|
||||
{@const instanceSet = new Set(
|
||||
profile.meta.profiles.map(i => i.instance),
|
||||
)}
|
||||
{#if instanceSet.size > 1}
|
||||
<Option disabled data-label="true">—</Option>
|
||||
{#each instanceSet as instance}
|
||||
<Option
|
||||
icon={ServerStack}
|
||||
value={encodeURIComponent(`instance-${instance}`)}
|
||||
>
|
||||
{instance}
|
||||
</Option>
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
</Location>
|
||||
<Sort
|
||||
name="sort"
|
||||
selected={data.sort}
|
||||
onchange={() => form?.requestSubmit()}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
{/snippet}
|
||||
</Header>
|
||||
|
||||
<form method="get" action="/communities" class="contents" bind:this={form}>
|
||||
<SearchBar bind:query={search} />
|
||||
|
||||
<div class="flex flex-row flex-wrap gap-4 mt-4 items-center">
|
||||
<Location
|
||||
name="type"
|
||||
selected={data.type}
|
||||
onchange={() => form?.requestSubmit()}
|
||||
>
|
||||
{#if !LINKED_INSTANCE_URL}
|
||||
{@const instanceSet = new Set(
|
||||
profile.meta.profiles.map(i => i.instance),
|
||||
)}
|
||||
{#if instanceSet.size > 1}
|
||||
<Option disabled data-label="true">—</Option>
|
||||
{#each instanceSet as instance}
|
||||
<Option
|
||||
icon={ServerStack}
|
||||
value={encodeURIComponent(`instance-${instance}`)}
|
||||
>
|
||||
{instance}
|
||||
</Option>
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
</Location>
|
||||
<Sort
|
||||
name="sort"
|
||||
selected={data.sort}
|
||||
onchange={() => form?.requestSubmit()}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
{#if navigating.to?.route.id == '/communities'}
|
||||
<div class="flex flex-col gap-3 mt-6">
|
||||
<div class="flex flex-col gap-3">
|
||||
{#each new Array(5) as _, index}
|
||||
{_}
|
||||
<div
|
||||
@@ -107,7 +109,7 @@
|
||||
{/if}
|
||||
|
||||
{#if showTop}
|
||||
<EndPlaceholder size="lg" margin="lg">
|
||||
<EndPlaceholder size="lg" margin="md">
|
||||
{$t('routes.search.top')}
|
||||
</EndPlaceholder>
|
||||
<div
|
||||
@@ -137,7 +139,7 @@
|
||||
{/if}
|
||||
|
||||
{#if data.communities.value.slice(showTop ? 3 : 0).length > 0}
|
||||
<EndPlaceholder size="lg" margin="lg">
|
||||
<EndPlaceholder size="lg" margin="md">
|
||||
{$t('routes.search.other')}
|
||||
</EndPlaceholder>
|
||||
{/if}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
let { children } = $props()
|
||||
</script>
|
||||
|
||||
<Header pageHeader>Instances</Header>
|
||||
<Tabs
|
||||
routes={[
|
||||
{
|
||||
@@ -15,4 +14,5 @@
|
||||
{ href: '/instances/blocked', name: 'Blocked' },
|
||||
]}
|
||||
></Tabs>
|
||||
<Header pageHeader>Instances</Header>
|
||||
{@render children?.()}
|
||||
@@ -0,0 +1,69 @@
|
||||
<script lang="ts">
|
||||
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { Spinner, TextInput } from 'mono-svelte'
|
||||
import { Check } from 'svelte-hero-icons'
|
||||
|
||||
let { data: passedData } = $props()
|
||||
let data = $state(passedData)
|
||||
|
||||
let filter = $state('')
|
||||
|
||||
let loading = $state(false)
|
||||
|
||||
function triggerFilter(filter: string) {
|
||||
if (!passedData.blocked) return
|
||||
loading = true
|
||||
data.blocked = passedData.blocked.filter(i => i.domain.includes(filter))
|
||||
loading = false
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if data}
|
||||
<div class="flex flex-col gap-4">
|
||||
<form onsubmit={() => triggerFilter(filter)}>
|
||||
<TextInput label={$t('filter.filter')} bind:value={filter}></TextInput>
|
||||
</form>
|
||||
{#if data.blocked && data.blocked.length > 0}
|
||||
{#if loading}
|
||||
<Spinner />
|
||||
{/if}
|
||||
<VirtualList
|
||||
items={data.blocked}
|
||||
useWindow={false}
|
||||
height={600}
|
||||
estimatedHeight={50}
|
||||
class="overflow-auto border rounded-2xl border-slate-200 dark:border-zinc-900 bg-white dark:bg-zinc-950
|
||||
divide-y divide-slate-200 dark:divide-zinc-900 w-full"
|
||||
>
|
||||
{#snippet item(index)}
|
||||
{#if data.blocked[index]}
|
||||
<div
|
||||
class="flex justify-between items-center first:pt-0 last:pb-0 my-3 px-6"
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium">{data.blocked[index].domain}</span>
|
||||
<span
|
||||
class="text-xs text-slate-600 dark:text-zinc-400 capitalize"
|
||||
>
|
||||
{data.blocked[index].software ?? 'Unknown'} • <RelativeDate
|
||||
date={publishedToDate(data.blocked[index].published)}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</VirtualList>
|
||||
{:else}
|
||||
<Placeholder
|
||||
icon={Check}
|
||||
title="No blocked instances"
|
||||
description="This instance likely has federation disabled."
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -3,27 +3,46 @@
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { Material } from 'mono-svelte'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { Spinner, TextInput } from 'mono-svelte'
|
||||
import { Check } from 'svelte-hero-icons'
|
||||
|
||||
let { data } = $props()
|
||||
let { data: passedData } = $props()
|
||||
let data = $state(passedData)
|
||||
|
||||
let filter = $state('')
|
||||
|
||||
let loading = $state(false)
|
||||
|
||||
function triggerFilter(filter: string) {
|
||||
if (!passedData.linked) return
|
||||
loading = true
|
||||
data.linked = passedData.linked.filter(i => i.domain.includes(filter))
|
||||
loading = false
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if data}
|
||||
<div class="flex flex-col md:flex-row gap-4">
|
||||
<Material
|
||||
class="h-full overflow-auto divide-y *:py-3 divide-slate-200 dark:divide-zinc-800 max-h-[48rem] w-full"
|
||||
>
|
||||
{#if data.linked && data.linked.length > 0}
|
||||
<VirtualList
|
||||
useWindow={false}
|
||||
items={data.linked}
|
||||
height={473}
|
||||
estimatedHeight={100}
|
||||
>
|
||||
{#snippet item(index)}
|
||||
<div class="flex flex-col gap-4">
|
||||
<form onsubmit={() => triggerFilter(filter)}>
|
||||
<TextInput label={$t('filter.filter')} bind:value={filter}></TextInput>
|
||||
</form>
|
||||
{#if data.linked && data.linked.length > 0}
|
||||
{#if loading}
|
||||
<Spinner />
|
||||
{/if}
|
||||
<VirtualList
|
||||
items={data.linked}
|
||||
useWindow={false}
|
||||
height={600}
|
||||
estimatedHeight={50}
|
||||
class="overflow-auto border rounded-2xl border-slate-200 dark:border-zinc-900 bg-white dark:bg-zinc-950
|
||||
divide-y divide-slate-200 dark:divide-zinc-900 w-full"
|
||||
>
|
||||
{#snippet item(index)}
|
||||
{#if data.linked[index]}
|
||||
<div
|
||||
class="flex justify-between items-center first:pt-0 last:pb-0 my-3"
|
||||
class="flex justify-between items-center first:pt-0 last:pb-0 my-3 px-6"
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium">{data.linked[index].domain}</span>
|
||||
@@ -36,15 +55,15 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
</VirtualList>
|
||||
{:else}
|
||||
<Placeholder
|
||||
icon={Check}
|
||||
title="No linked instances"
|
||||
description="This instance likely has federation disabled."
|
||||
/>
|
||||
{/if}
|
||||
</Material>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</VirtualList>
|
||||
{:else}
|
||||
<Placeholder
|
||||
icon={Check}
|
||||
title="No linked instances"
|
||||
description="This instance doesn't block any others."
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
Reference in new issue
Block a user