design: redesign community/site cards on desktop

This commit is contained in:
James Xylight committed 2025-08-30 20:55:24 -07:00
1 parent 10aed8559e
commit eee9621afe
11 files changed
+299 -252

No files matched your search

+89 -81
View File
@@ -6,13 +6,19 @@
import { settings } from '$lib/settings.svelte'
import type { PersonView, SiteView, Tagline } from 'lemmy-js-client'
import { Badge } from 'mono-svelte'
import { Icon, ServerStack } from 'svelte-hero-icons'
import Link from '../input/Link.svelte'
import {
BuildingOffice,
Icon,
Newspaper,
ServerStack,
} from 'svelte-hero-icons'
import type { ClassValue, HTMLAttributes } from 'svelte/elements'
import EndPlaceholder from '../ui/EndPlaceholder.svelte'
import Expandable from '../ui/Expandable.svelte'
import LabelStat from '../ui/LabelStat.svelte'
import SidebarButton from '../ui/sidebar/SidebarButton.svelte'
import ItemList from './generic/ItemList.svelte'
import { optimizeImageURL } from './post/helpers'
import type { ClassValue, HTMLAttributes } from 'svelte/elements'
interface Props extends HTMLAttributes<HTMLDivElement> {
site: SiteView
@@ -38,10 +44,7 @@
]}
>
{#if site.site.banner}
<div
class="rounded-xl
bg-slate-100 dark:bg-zinc-925"
>
<div class="rounded-xl bg-slate-100 dark:bg-zinc-925">
<img
src={optimizeImageURL(site.site.banner, 512)}
alt="Site banner"
@@ -50,8 +53,10 @@
/>
</div>
{/if}
<Avatar width={32} url={site.site.icon} alt="" circle={false} />
<h2 class="font-medium text-lg -my-2">{site.site.name}</h2>
<div class="mx-3 space-y-3">
<Avatar width={32} url={site.site.icon} alt="" circle={false} />
<h2 class="font-medium text-lg -my-2">{site.site.name}</h2>
</div>
<div class="flex flex-col gap-1">
{#if taglines && taglines.length > 0}
<Markdown
@@ -60,85 +65,88 @@
/>
{/if}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={settings.expand.about}>
{#snippet title()}
<span class="flex items-center gap-1 py-1 px-2 w-full">
{$t('cards.site.about')}
</span>
{/snippet}
<Markdown source={site.site.description} />
<div class="my-4"></div>
<Markdown source={site.site.sidebar} />
<EndPlaceholder size="xs" margin="sm">
{$t('nav.menu.instance')}
</EndPlaceholder>
<SidebarButton
href="/modlog"
label={$t('routes.modlog.title')}
icon={Newspaper}
/>
<SidebarButton
href="/legal"
label={$t('routes.legal.title')}
icon={BuildingOffice}
/>
<SidebarButton
href="/instances"
label={$t('routes.instances')}
icon={ServerStack}
/>
{#if version}
<div class="w-max">
<Badge label="Lemmy version">
<Icon src={ServerStack} micro size="14" />
{version}
</Badge>
</div>
{/if}
</Expandable>
<EndPlaceholder size="xs" margin="sm">
{$t('cards.site.stats')}
</EndPlaceholder>
<div class="flex flex-row gap-4 flex-wrap px-3">
<LabelStat
label={$t('content.users')}
content={site.counts.users.toString()}
formatted
/>
<LabelStat
label={$t('content.posts')}
content={site.counts.posts.toString()}
formatted
/>
<LabelStat
label={$t('content.communities')}
content={site.counts.communities.toString()}
formatted
/>
</div>
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={settings.expand.stats}>
{#snippet title()}
<span class="flex items-center gap-1 py-1 px-2 w-full">
{$t('cards.site.stats')}
</span>
{/snippet}
<div class="flex flex-row gap-4 flex-wrap">
<LabelStat
label={$t('content.users')}
content={site.counts.users.toString()}
formatted
/>
<LabelStat
label={$t('content.posts')}
content={site.counts.posts.toString()}
formatted
/>
<LabelStat
label={$t('content.communities')}
content={site.counts.communities.toString()}
formatted
/>
</div>
</Expandable>
{#if admins}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={settings.expand.team}>
<EndPlaceholder size="xs" margin="sm">
{$t('common.info')}
</EndPlaceholder>
<div class="space-y-3 px-1.5 text-sm">
<Expandable bind:open={settings.expand.about}>
{#snippet title()}
<span class="flex items-center gap-1 py-1 px-2 w-full">
{$t('cards.site.admins')}
{$t('cards.site.about')}
</span>
{/snippet}
<ItemList
items={admins.map(i => ({
id: i.person.id,
name: i.person.display_name || i.person.name,
url: userLink(i.person),
avatar: i.person.avatar,
instance: new URL(i.person.actor_id).hostname,
}))}
/>
</Expandable>
{/if}
<Markdown source={site.site.description} />
<div class="my-4"></div>
<Markdown source={site.site.sidebar} />
<div class="flex flex-row flex-wrap gap-1 my-2 text-xs">
<Link highlight href="/modlog">
{$t('routes.modlog.title')}
</Link>
•
<Link highlight href="/legal">
{$t('routes.legal.title')}
</Link>
•
<Link highlight href="/instances">
{$t('routes.instances')}
</Link>
{#if version}
<div class="w-max">
<Badge label="Lemmy version">
<Icon src={ServerStack} micro size="14" />
{version}
</Badge>
</div>
{/if}
</Expandable>
{#if admins}
<Expandable bind:open={settings.expand.team}>
{#snippet title()}
<span class="flex items-center gap-1 py-1 px-2 w-full">
{$t('cards.site.admins')}
</span>
{/snippet}
<ItemList
items={admins.map(i => ({
id: i.person.id,
name: i.person.display_name || i.person.name,
url: userLink(i.person),
avatar: i.person.avatar,
instance: new URL(i.person.actor_id).hostname,
}))}
/>
</Expandable>
{/if}
</div>
</div>
</aside>
@@ -104,8 +104,11 @@
Newspaper,
NoSymbol,
Plus,
ShieldCheck,
} from 'svelte-hero-icons'
import ItemList from '../generic/ItemList.svelte'
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
let loading = $state({
blocking: false,
@@ -156,64 +159,188 @@
{:then community_view}
<aside
class={[
'min-w-full pt-0 text-slate-600 dark:text-zinc-400 flex flex-col gap-4 text-sm',
'min-w-full pt-0 text-slate-600 dark:text-zinc-400 flex flex-col gap-1',
clazz,
]}
>
<Entity
name={community_view.community.title}
label="!{fullCommunityName(
community_view.community.name,
community_view.community.actor_id,
)}"
>
{#snippet customIcon()}
<Avatar
width={32}
url={community_view.community.icon}
alt={community_view.community.name}
circle={false}
<div class="px-3 overflow-hidden">
<Entity
name={community_view.community.title}
label="!{fullCommunityName(
community_view.community.name,
community_view.community.actor_id,
)}"
>
{#snippet customIcon()}
<Avatar
width={32}
url={community_view.community.icon}
alt={community_view.community.name}
circle={false}
/>
{/snippet}
</Entity>
</div>
<EndPlaceholder size="xs" margin="sm">
{$t('form.post.community')}
</EndPlaceholder>
{#if profile.current?.jwt}
{@const subscribed = profile.current.user?.follows.some(
i => i.community.id == community_view.community.id,
)}
<Button
disabled={loading.subscribing}
loading={loading.subscribing}
size="md"
rounding="xl"
color={subscribed ? 'secondary' : 'primary'}
onclick={() => subscribe(community_view)}
class="px-4 relative z-[inherit]"
alignment="left"
>
{#snippet prefix()}
<Icon
src={community_view.subscribed == 'Subscribed' ? Check : Plus}
mini
size="16"
/>
{/snippet}
{subscribed
? $t('cards.community.subscribed')
: $t('cards.community.subscribe')}
</Button>
{/if}
{#if profile.current?.user && amMod(profile.current.user, community_view.community)}
<SidebarButton
href="/c/{fullCommunityName(
community_view.community.name,
community_view.community.actor_id,
)}/settings"
rounding="xl"
icon={Cog6Tooth}
label={$t('routes.profile.edit')}
/>
{/if}
<Menu placement="bottom-start">
{#snippet target(attachment)}
<SidebarButton
{@attach attachment}
label={$t('post.actions.more.label')}
rounding="xl"
icon={EllipsisHorizontal}
/>
{/snippet}
</Entity>
<MenuButton href="/modlog?community={community_view.community.id}">
<Icon src={Newspaper} size="16" mini />
{$t('cards.community.modlog')}
</MenuButton>
{#if profile.current?.jwt}
{#if profile.current.user && amMod(profile.current.user, community_view.community)}
<MenuButton
color="success-subtle"
href="/moderation?community={community_view.community.id}"
>
<Icon src={ShieldCheck} size="16" micro />
{$t('routes.moderation.feed')}
</MenuButton>
{/if}
<MenuButton
color="danger-subtle"
size="lg"
onclick={() =>
block(community_view.community.id, !community_view.blocked)}
>
{#snippet prefix()}
<Icon src={NoSymbol} size="16" mini />
{/snippet}
{community_view.blocked
? $t('cards.community.unblock')
: $t('cards.community.block')}
</MenuButton>
{#if profile.current?.user}
<MenuButton
color="danger-subtle"
size="lg"
onclick={() => blockInstance(community_view.community.instance_id)}
>
{#snippet prefix()}
<Icon src={BuildingOffice2} size="16" mini />
{/snippet}
{$t('cards.community.blockInstance')}
</MenuButton>
{/if}
{#if profile.current?.user && isAdmin(profile.current.user)}
<MenuButton
color="danger-subtle"
onclick={() =>
modal({
title: $t('admin.purgeCommunity.title'),
body: `${community_view.community.title}: ${$t('admin.purgeCommunity.warning')}`,
actions: [
action({
close: true,
content: $t('common.cancel'),
}),
action({
action: () => purgeCommunity(community_view.community.id),
close: true,
content: $t('admin.purge'),
type: 'danger',
icon: Fire,
}),
],
dismissable: true,
type: 'error',
})}
>
{#snippet prefix()}
<Icon src={Fire} size="16" mini />
{/snippet}
{$t('admin.purge')}
</MenuButton>
{/if}
{/if}
</Menu>
<EndPlaceholder size="xs" margin="sm">
{$t('cards.site.stats')}
</EndPlaceholder>
<div class="flex flex-col gap-1">
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={settings.expand.about} class="pt-0!">
<div class="flex flex-row gap-4 flex-wrap px-3">
<LabelStat
label={$t('cards.community.members')}
content={community_view.counts.subscribers.toString()}
formatted
/>
<LabelStat
label={$t('content.posts')}
content={community_view.counts.posts.toString()}
formatted
/>
<LabelStat
label={$t('cards.community.activeDay')}
content={community_view.counts.users_active_day.toString()}
formatted
/>
</div>
<EndPlaceholder size="xs" margin="sm">
{$t('common.info')}
</EndPlaceholder>
<div class="space-y-3 px-1.5 text-sm">
<Expandable bind:open={settings.expand.about}>
{#snippet title()}
<span class="py-1 px-1 flex gap-1 items-center w-full">
<span class="px-2 py-1 w-full">
{$t('cards.site.about')}
</span>
{/snippet}
<Markdown source={community_view.community.description} />
</Expandable>
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={settings.expand.stats}>
{#snippet title()}
<span class="py-1 px-1 flex gap-1 items-center w-full">
{$t('cards.site.stats')}
</span>
{/snippet}
<div class="flex flex-row gap-4 flex-wrap">
<LabelStat
label={$t('cards.community.members')}
content={community_view.counts.subscribers.toString()}
formatted
/>
<LabelStat
label={$t('content.posts')}
content={community_view.counts.posts.toString()}
formatted
/>
</div>
</Expandable>
{#if moderators && moderators.length > 0}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={settings.expand.team}>
{#snippet title()}
<span class="flex items-center gap-1 py-1 px-2 w-full">
<span class="px-2 py-1 w-full">
{$t('cards.community.moderators')}
</span>
{/snippet}
@@ -229,117 +356,5 @@
</Expandable>
{/if}
</div>
<div class="flex flex-row items-center gap-1 sticky bottom-0 w-full">
{#if profile.current?.jwt}
<Button
disabled={loading.subscribing}
loading={loading.subscribing}
size="md"
rounding="pill"
color={community_view.subscribed == 'Subscribed'
? 'secondary'
: 'primary'}
onclick={() => subscribe(community_view)}
class="px-4 relative z-[inherit]"
>
{#snippet prefix()}
<Icon
src={community_view.subscribed == 'Subscribed' ? Check : Plus}
mini
size="16"
/>
{/snippet}
{community_view.subscribed == 'Subscribed' ||
community_view.subscribed == 'Pending'
? $t('cards.community.subscribed')
: $t('cards.community.subscribe')}
</Button>
{/if}
{#if profile.current?.user && amMod(profile.current.user, community_view.community)}
<Button
href="/c/{fullCommunityName(
community_view.community.name,
community_view.community.actor_id,
)}/settings"
size="square-md"
rounding="pill"
>
{#snippet prefix()}
<Icon src={Cog6Tooth} mini size="16" />
{/snippet}
</Button>
{/if}
<Menu placement="top-end">
{#snippet target(attachment)}
<Button {@attach attachment} size="square-md" rounding="pill">
{#snippet prefix()}
<Icon src={EllipsisHorizontal} size="16" mini />
{/snippet}
</Button>
{/snippet}
<MenuButton href="/modlog?community={community_view.community.id}">
<Icon src={Newspaper} size="16" mini />
{$t('cards.community.modlog')}
</MenuButton>
{#if profile.current?.jwt}
<MenuButton
color="danger-subtle"
size="lg"
onclick={() =>
block(community_view.community.id, !community_view.blocked)}
>
{#snippet prefix()}
<Icon src={NoSymbol} size="16" mini />
{/snippet}
{community_view.blocked
? $t('cards.community.unblock')
: $t('cards.community.block')}
</MenuButton>
{#if profile.current?.user}
<MenuButton
color="danger-subtle"
size="lg"
onclick={() =>
blockInstance(community_view.community.instance_id)}
>
{#snippet prefix()}
<Icon src={BuildingOffice2} size="16" mini />
{/snippet}
{$t('cards.community.blockInstance')}
</MenuButton>
{/if}
{#if profile.current?.user && isAdmin(profile.current.user)}
<MenuButton
color="danger-subtle"
onclick={() =>
modal({
title: $t('admin.purgeCommunity.title'),
body: `${community_view.community.title}: ${$t('admin.purgeCommunity.warning')}`,
actions: [
action({
close: true,
content: $t('common.cancel'),
}),
action({
action: () => purgeCommunity(community_view.community.id),
close: true,
content: $t('admin.purge'),
type: 'danger',
icon: Fire,
}),
],
dismissable: true,
type: 'error',
})}
>
{#snippet prefix()}
<Icon src={Fire} size="16" mini />
{/snippet}
{$t('admin.purge')}
</MenuButton>
{/if}
{/if}
</Menu>
</div>
</aside>
{/await}
@@ -164,11 +164,11 @@
/>
<div class="flex flex-row gap-4 flex-wrap *:flex-1">
<ImageInputUpload
imageUrl={formData.icon}
bind:imageUrl={formData.icon}
label={$t('routes.admin.config.icon')}
/>
<ImageInputUpload
imageUrl={formData.banner}
bind:imageUrl={formData.banner}
label={$t('routes.admin.config.banner')}
/>
</div>
@@ -40,6 +40,7 @@
blocked?: boolean
banner?: boolean
class?: string
compact?: 'lg'
}
let {
@@ -50,10 +51,14 @@
blocked = false,
banner = !(settings.nsfwBlur && community.nsfw),
class: clazz = '',
compact,
...rest
}: Props = $props()
</script>
<EntityHeader
{...rest}
{compact}
banner={banner ? community.banner : undefined}
avatar={community.icon}
name={community.title}
@@ -98,7 +103,7 @@
</button>
{/snippet}
{#if moderators.length > 0}
<Expandable class="">
<Expandable class={[compact == 'lg' && 'lg:hidden']}>
{#snippet title()}
{$t('cards.community.moderators')}
<hr class="flex-1 border-slate-200 dark:border-zinc-800 mx-3" />
@@ -114,7 +119,7 @@
/>
</Expandable>
{/if}
<div class="flex items-center gap-2 h-max w-max">
<div class={["flex items-center gap-2 h-max w-max", compact == 'lg' && 'lg:hidden']}>
{#if profile.current?.jwt}
<Subscribe
community={{
@@ -148,13 +148,13 @@
{:else}
<div class="flex flex-row items-center gap-2">
<Button
size="square-md"
rounding="pill"
rounding="xl"
color="ghost"
onclick={() =>
modal({ title: $t('form.post.community'), snippet: communityInfo })}
>
<Icon src={InformationCircle} size="16" mini />
{$t('post.actions.more.label')}
</Button>
<Subscribe {community}>
{#snippet children({ subscribe, subscribing })}
@@ -191,7 +191,7 @@
? $t('cards.community.subscribed')
: $t('cards.community.subscribe')}
color={subscribed ? 'secondary' : 'primary'}
rounding="pill"
rounding="xl"
class={[
subscribed && 'text-slate-600 dark:text-zinc-400',
' h-8.5 rounded-full',
@@ -227,7 +227,7 @@
{/if}
{/key}
{#if settings.infiniteScroll && browser}
{#if settings.infiniteScroll && browser && posts.length > 0}
{#if error}
<div
class="flex flex-col justify-center items-center
+22 -6
View File
@@ -22,6 +22,7 @@
nameDetail?: import('svelte').Snippet
actions?: import('svelte').Snippet
children?: import('svelte').Snippet
compact?: 'lg'
}
let {
@@ -36,12 +37,18 @@
nameDetail,
actions,
children,
compact,
...rest
}: Props = $props()
</script>
<div {...rest} class={['z-10 text-sm contents w-full', clazz]}>
<div class="absolute inset-0 h-96 overflow-x-hidden -z-10">
<div
class={[
compact == 'lg' && 'lg:hidden',
'absolute inset-0 h-96 overflow-x-hidden -z-10',
]}
>
<img
src={banner || avatar}
class="w-full h-64 object-cover blur-3xl opacity-30 dark:opacity-30"
@@ -49,12 +56,11 @@
alt="User banner"
/>
</div>
{#if banner || avatar}
{#if banner}
<div class="relative overflow-hidden rounded-xl">
<img
src={banner || avatar}
src={banner}
class="w-full object-cover h-48 rounded-t-xl bg-white dark:bg-zinc-900 rounded-xl"
class:blur-xl={!banner}
height="192"
alt="User banner"
/>
@@ -65,7 +71,11 @@
width={96}
url={avatar}
alt={name}
class="ring-slate-25 bg-slate-25 dark:bg-zinc-925 -mt-12 ml-4 ring-6 relative dark:ring-zinc-950"
circle={false}
class={[
'ring-slate-25 bg-slate-25 dark:bg-zinc-925 ring-6 relative dark:ring-zinc-950 rounded-3xl!',
banner && '-mt-12 ml-4',
]}
/>
<div class="py-4 flex flex-col xl:flex-row gap-4">
<div class="flex flex-col flex-1">
@@ -91,7 +101,12 @@
{/if}
</div>
{#if stats.length > 0}
<div class="text-sm flex flex-row flex-wrap overflow-hidden gap-4 h-full">
<div
class={[
compact == 'lg' && 'lg:hidden',
'text-sm flex flex-row flex-wrap overflow-hidden gap-4 h-full',
]}
>
{#each stats as stat}
<div class="">
<div class="text-slate-600 dark:text-zinc-500 text-sm font-medium">
@@ -117,6 +132,7 @@
{#if bio}
<div
class={[
compact == 'lg' && 'lg:hidden',
'relative w-full mb-4 text-base',
center ? 'text-center' : 'text-left',
]}
+2 -1
View File
@@ -1,10 +1,11 @@
<script lang="ts">
import { Disclosure } from 'mono-svelte'
import { Minus, Plus, Icon } from 'svelte-hero-icons'
import type { ClassValue } from 'svelte/elements'
interface Props {
open?: boolean
icon?: boolean
class?: string
class?: ClassValue
title?: import('svelte').Snippet<[boolean | undefined]>
extended?: import('svelte').Snippet
content?: import('svelte').Snippet
+1 -1
View File
@@ -65,7 +65,7 @@
style: 'grid-area: main',
})}
{@render suffix?.({
class: `max-lg:hidden w-full sticky lg:top-16 h-max max-h-screen overflow-auto left-0 bg-slate-100 dark:bg-zinc-950 z-40`,
class: `max-lg:hidden flex w-full sticky top-0 lg:top-16 left-0 max-h-[calc(100vh-4rem)] overflow-auto bg-slate-100 dark:bg-zinc-950 z-40`,
style: 'grid-area: suffix;',
})}
</div>
+1
View File
@@ -71,6 +71,7 @@
moderators={data.community.value.moderators}
counts={data.community.value.community_view.counts}
class="w-full relative"
compact="lg"
/>
</div>
{#snippet extended()}
+2 -1
View File
@@ -157,6 +157,7 @@
class="flex flex-col gap-4 h-full w-full flex-2/3"
onsubmit={preventDefault(submit)}
>
<ErrorContainer scope={page.url.pathname} />
<Button href="/accounts" class="inline-block mb-4 w-max" rounding="pill">
<Icon src={ArrowLeft} size="16" micro />
{$t('common.back')}
@@ -296,8 +297,8 @@
</form>
{:else if stage == 'verify'}
<div class="flex-2/3 flex flex-col h-full justify-center gap-8">
<h2 class="font-medium text-3xl">{$t('toast.verifyEmail')}</h2>
<ErrorContainer scope={page.url.pathname} />
<h2 class="font-medium text-3xl">{$t('toast.verifyEmail')}</h2>
<form
onsubmit={e => {
e.preventDefault()