feat: color overhaul
This commit is contained in:
1 parent
8fc452951b
commit
e5fbf7493c
22 files changed
+234
-243
No files matched your search
@@ -4,42 +4,71 @@
|
||||
import { page } from '$app/stores'
|
||||
import {
|
||||
ChatBubbleOvalLeftEllipsis,
|
||||
Check,
|
||||
GlobeAmericas,
|
||||
Icon,
|
||||
InformationCircle,
|
||||
PencilSquare,
|
||||
Plus,
|
||||
QuestionMarkCircle,
|
||||
UserGroup,
|
||||
} from 'svelte-hero-icons'
|
||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||
import Subscribe from './Subscribe.svelte'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import {
|
||||
DOMAIN_REGEX,
|
||||
DOMAIN_REGEX_FORMS,
|
||||
isSubscribed,
|
||||
searchParam,
|
||||
} from '$lib/util.js'
|
||||
import { addSubscription } from '$lib/lemmy/user.js'
|
||||
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { Button, Select, TextInput } from 'mono-svelte'
|
||||
import { Button, Material, Popover, Select, TextInput } from 'mono-svelte'
|
||||
import Sort from '$lib/components/lemmy/Sort.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
||||
|
||||
export let data
|
||||
|
||||
let search = ''
|
||||
let search = data.query || ''
|
||||
let instance = ''
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Communities</title>
|
||||
</svelte:head>
|
||||
|
||||
<h1 class="text-2xl font-bold">Communities</h1>
|
||||
<p class="text-slate-600 dark:text-zinc-400 mt-2">
|
||||
Can't find a community on your home instance? Go to the <a
|
||||
href="/search"
|
||||
class="text-blue-500 hover:underline"
|
||||
<h1 class="text-2xl font-bold">
|
||||
<span>Communities</span>
|
||||
<Popover
|
||||
openOnHover
|
||||
class="!inline-flex"
|
||||
targetClass="inline"
|
||||
origin="bottom-center"
|
||||
>
|
||||
search
|
||||
</a>
|
||||
page, and search with this syntax:
|
||||
<code>!community@instance.com</code>
|
||||
</p>
|
||||
<Icon
|
||||
src={InformationCircle}
|
||||
size="20"
|
||||
mini
|
||||
slot="target"
|
||||
class="!inline"
|
||||
/>
|
||||
<Material slot="popover" color="distinct" class="w-72">
|
||||
<p class="font-normal">
|
||||
Can't find a community on your home instance? Go to the <a
|
||||
href="/search"
|
||||
class="text-blue-500 hover:underline"
|
||||
>
|
||||
search
|
||||
</a>
|
||||
page, and search with this syntax:
|
||||
<code>!community@instance.com</code>
|
||||
</p>
|
||||
</Material>
|
||||
</Popover>
|
||||
</h1>
|
||||
<div class="flex flex-row flex-wrap gap-4 mt-4">
|
||||
<Select
|
||||
bind:value={data.type}
|
||||
@@ -54,124 +83,33 @@
|
||||
<option value="Subscribed">Subscribed</option>
|
||||
</Select>
|
||||
<Sort selected={data.sort} />
|
||||
<div class="flex flex-col sm:flex-row gap-2 sm:ml-auto items-center">
|
||||
<TextInput
|
||||
bind:value={search}
|
||||
on:change={() => () => searchParam($page.url, 'q', search, 'page')}
|
||||
/>
|
||||
<Button
|
||||
on:click={() => searchParam($page.url, 'q', search, 'page')}
|
||||
color="ghost"
|
||||
class="h-max"
|
||||
>
|
||||
Search
|
||||
</Button>
|
||||
</div>
|
||||
<form
|
||||
on:submit|preventDefault={() =>
|
||||
goto(`/search?q=${search}&type=Communities`)}
|
||||
class="flex flex-col sm:flex-row gap-2 sm:ml-auto items-center"
|
||||
>
|
||||
<TextInput bind:value={search} />
|
||||
<Button submit color="ghost" class="h-max">Search</Button>
|
||||
</form>
|
||||
</div>
|
||||
<ul class="flex flex-col divide-y dark:divide-zinc-800">
|
||||
{#if data.communities.length == 0}
|
||||
<div
|
||||
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center py-8"
|
||||
>
|
||||
<Icon src={QuestionMarkCircle} size="32" solid />
|
||||
<h1 class="font-bold text-2xl">No communities</h1>
|
||||
<p class="mt-2 text-center">
|
||||
There are no communities with that name. Try refining your search.
|
||||
</p>
|
||||
</div>
|
||||
<Placeholder
|
||||
icon={QuestionMarkCircle}
|
||||
title="No communities"
|
||||
description="There are no communities that match this filter. Try refining your
|
||||
search."
|
||||
/>
|
||||
{/if}
|
||||
{#each data.communities as community}
|
||||
<li class="py-3">
|
||||
<div
|
||||
class="
|
||||
flex flex-col gap-1 text-sm max-w-full"
|
||||
>
|
||||
<div class="flex flex-row items-center">
|
||||
<span
|
||||
class="break-words max-w-full w-max text-base font-bold text-sky-400 hover:underline"
|
||||
>
|
||||
<CommunityLink
|
||||
showInstance={false}
|
||||
avatar
|
||||
community={community.community}
|
||||
/>
|
||||
</span>
|
||||
<div class="ml-auto">
|
||||
<Subscribe {community} let:subscribe let:subscribing>
|
||||
<Button
|
||||
disabled={subscribing || !$profile?.jwt}
|
||||
loading={subscribing}
|
||||
on:click={async () => {
|
||||
const res = await subscribe()
|
||||
|
||||
if (res) {
|
||||
community.subscribed =
|
||||
res.community_view.subscribed != 'NotSubscribed'
|
||||
? 'Subscribed'
|
||||
: 'NotSubscribed'
|
||||
|
||||
addSubscription(
|
||||
community.community,
|
||||
res.community_view.subscribed == 'Subscribed' ||
|
||||
res.community_view.subscribed == 'Pending'
|
||||
)
|
||||
}
|
||||
}}
|
||||
color={community.subscribed == 'Subscribed'
|
||||
? 'primary'
|
||||
: 'ghost'}
|
||||
>
|
||||
{community.subscribed == 'Subscribed'
|
||||
? 'Subscribed'
|
||||
: 'Subscribe'}
|
||||
</Button>
|
||||
</Subscribe>
|
||||
</div>
|
||||
</div>
|
||||
<span class="opacity-80 mb-2">
|
||||
{new URL(community.community.actor_id).hostname}
|
||||
</span>
|
||||
<div class="flex flex-row gap-3 items-center">
|
||||
<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>
|
||||
<CommunityItem {community} />
|
||||
{/each}
|
||||
</ul>
|
||||
{#if data.communities.length > 0}
|
||||
<div class="mt-2 w-full">
|
||||
<Pageination
|
||||
page={Number($page.url.searchParams.get('page')) || 1}
|
||||
on:change={(p) => {
|
||||
$page.url.searchParams.set('page', p.detail.toString())
|
||||
|
||||
goto($page.url.toString(), {
|
||||
invalidateAll: true,
|
||||
})
|
||||
}}
|
||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -25,6 +25,8 @@ export async function load({ url, fetch }) {
|
||||
})),
|
||||
type: type,
|
||||
sort: sort,
|
||||
query: query,
|
||||
page: page,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
@@ -37,6 +39,8 @@ export async function load({ url, fetch }) {
|
||||
})),
|
||||
type: type,
|
||||
sort: sort,
|
||||
query: query,
|
||||
page: page,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user