feat: Add community list
This commit is contained in:
1 parent
633dc33714
commit
89bd20b8d0
5 files changed
+142
-42
No files matched your search
@@ -1,33 +1,35 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Logo from '$lib/components/Logo.svelte'
|
import Link from '$lib/components/Link.svelte'
|
||||||
|
import Logo from '$lib/components/Logo.svelte'
|
||||||
|
|
||||||
export let routes: string[] = []
|
export let routes: string[] = []
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
class="flex top-0 z-20 flex-row gap-4 items-center mt-2 w-full h-16
|
class="flex top-0 z-20 flex-row gap-4 items-center mt-2 w-full h-16
|
||||||
max-w-5xl mx-auto px-6"
|
max-w-5xl mx-auto px-6"
|
||||||
>
|
>
|
||||||
<div class="flex flex-row gap-2 items-center mr-auto">
|
<div class="flex flex-row gap-2 items-center mr-auto">
|
||||||
<a href="/">
|
<a href="/">
|
||||||
<Logo width={40} />
|
<Logo width={40} />
|
||||||
</a>
|
</a>
|
||||||
{#if routes.length != 0}
|
{#if routes.length != 0}
|
||||||
{#each routes as route}
|
{#each routes as route}
|
||||||
<svg
|
<svg
|
||||||
fill="none"
|
fill="none"
|
||||||
height="32"
|
height="32"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
width="32"
|
width="32"
|
||||||
class="stroke-1 opacity-20 stroke-black dark:stroke-white"
|
class="stroke-1 opacity-20 stroke-black dark:stroke-white"
|
||||||
>
|
>
|
||||||
<path d="M16.88 3.549L7.12 20.451" />
|
<path d="M16.88 3.549L7.12 20.451" />
|
||||||
</svg>
|
</svg>
|
||||||
<span>{route}</span>
|
<span>{route}</span>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<Link href="/communities">Communities</Link>
|
||||||
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100 dark:bg-zinc-800"
|
<div
|
||||||
/>
|
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100 dark:bg-zinc-800"
|
||||||
|
/>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { GetCommunityResponse } from 'lemmy-js-client'
|
import type { GetCommunityResponse } from 'lemmy-js-client'
|
||||||
|
import Avatar from '../../post/[id]/Avatar.svelte'
|
||||||
|
|
||||||
export let data: GetCommunityResponse
|
export let data: GetCommunityResponse
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<div class="flex flex-row gap-4 items-center">
|
<div class="flex flex-row gap-4 items-center">
|
||||||
<img
|
<Avatar
|
||||||
src={data.community_view.community.icon}
|
url={data.community_view.community.icon ??
|
||||||
alt="test"
|
`https://api.dicebear.com/6.x/initials/svg?seed=${data.community_view.community.name}`}
|
||||||
class="rounded-full bg-white border-slate-200 border p-2"
|
alt={data.community_view.community.title}
|
||||||
width={64}
|
width={64}
|
||||||
height={64}
|
/>
|
||||||
/>
|
<h1 class="font-bold text-xl">
|
||||||
<h1 class="font-bold text-xl">
|
{data.community_view.community.name}
|
||||||
{data.community_view.community.name}
|
</h1>
|
||||||
</h1>
|
</div>
|
||||||
</div>
|
<slot />
|
||||||
<slot />
|
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { lemmy } from '$lib/lemmy.js'
|
||||||
|
import type { ListingType } from 'lemmy-js-client'
|
||||||
|
|
||||||
|
export function load(req) {
|
||||||
|
const type = req.url.searchParams.get('listingType') as ListingType
|
||||||
|
const page = Number(req.url.searchParams.get('page')) || 1
|
||||||
|
|
||||||
|
return lemmy.listCommunities({
|
||||||
|
limit: 40,
|
||||||
|
page: page,
|
||||||
|
sort: 'Active',
|
||||||
|
type_: type,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
import MultiSelect from '$lib/components/MultiSelect.svelte'
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
import {
|
||||||
|
ChatBubbleLeftEllipsis,
|
||||||
|
ChatBubbleOvalLeftEllipsis,
|
||||||
|
Icon,
|
||||||
|
PencilSquare,
|
||||||
|
UserGroup,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
|
import CommunityLink from '$lib/components/CommunityLink.svelte'
|
||||||
|
|
||||||
|
export let data
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<MultiSelect
|
||||||
|
options={['Subscribed', 'Local', 'All']}
|
||||||
|
selected={$page.url.searchParams.get('type') ?? 'Local'}
|
||||||
|
on:select={(e) => {
|
||||||
|
const url = $page.url
|
||||||
|
url.searchParams.set('type', e.detail)
|
||||||
|
url.searchParams.delete('page')
|
||||||
|
goto(url, {
|
||||||
|
invalidateAll: true,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ul class="flex flex-col">
|
||||||
|
{#each data.communities as community}
|
||||||
|
<li>
|
||||||
|
<div
|
||||||
|
class="py-4 border-b border-black/20 dark:border-white/20
|
||||||
|
flex flex-col gap-1 text-sm"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="break-words max-w-full w-max text-base font-bold text-sky-400 hover:underline"
|
||||||
|
>
|
||||||
|
<CommunityLink community={community.community} />
|
||||||
|
</span>
|
||||||
|
{#if !community.community.local}
|
||||||
|
<span class="opacity-80">
|
||||||
|
{new URL(community.community.actor_id).hostname}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
<div class="flex flex-row gap-3 items-center mt-2">
|
||||||
|
<div class="flex flex-row gap-1 items-center">
|
||||||
|
<Icon src={UserGroup} width={16} mini />
|
||||||
|
<span>
|
||||||
|
{Intl.NumberFormat('en', { notation: 'compact' }).format(
|
||||||
|
community.counts.subscribers
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-1 items-center">
|
||||||
|
<Icon src={PencilSquare} mini width={16} />
|
||||||
|
<span>
|
||||||
|
{Intl.NumberFormat('en', { notation: 'compact' }).format(
|
||||||
|
community.counts.posts
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-1 items-center">
|
||||||
|
<Icon src={ChatBubbleOvalLeftEllipsis} mini width={16} />
|
||||||
|
<span>
|
||||||
|
{Intl.NumberFormat('en', { notation: 'compact' }).format(
|
||||||
|
community.counts.comments
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
@@ -68,7 +68,11 @@
|
|||||||
<button aria-label="Upvote" class="p-1 px-1.5">
|
<button aria-label="Upvote" class="p-1 px-1.5">
|
||||||
<Icon src={ChevronUp} mini width={20} height={20} />
|
<Icon src={ChevronUp} mini width={20} height={20} />
|
||||||
</button>
|
</button>
|
||||||
<span class="text-sm">{postRes.counts.score}</span>
|
<span class="text-sm">
|
||||||
|
{Intl.NumberFormat('en', { notation: 'compact' }).format(
|
||||||
|
postRes.counts.score
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
<button aria-label="Downvote" class="p-1 px-1.5">
|
<button aria-label="Downvote" class="p-1 px-1.5">
|
||||||
<Icon src={ChevronDown} mini width={20} height="20}" />
|
<Icon src={ChevronDown} mini width={20} height="20}" />
|
||||||
</button>
|
</button>
|
||||||
@@ -80,7 +84,11 @@
|
|||||||
href="/post/{postRes.post.id}"
|
href="/post/{postRes.post.id}"
|
||||||
>
|
>
|
||||||
<Icon src={ChatBubbleLeft} width={16} height={16} />
|
<Icon src={ChatBubbleLeft} width={16} height={16} />
|
||||||
<span class="text-sm">{postRes.counts.comments}</span>
|
<span class="text-sm">
|
||||||
|
{Intl.NumberFormat('en', { notation: 'compact' }).format(
|
||||||
|
postRes.counts.comments
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user