From eee9621afe99a1869ff8464096ff934d78f53315 Mon Sep 17 00:00:00 2001 From: James Xylight Date: Sat, 30 Aug 2025 20:55:24 -0700 Subject: [PATCH] design: redesign community/site cards on desktop --- src/lib/components/lemmy/SiteCard.svelte | 170 ++++----- .../lemmy/community/CommunityCard.svelte | 323 +++++++++--------- .../lemmy/community/CommunityForm.svelte | 4 +- .../lemmy/community/CommunityHeader.svelte | 9 +- .../lemmy/community/CommunityItem.svelte | 6 +- .../lemmy/post/feed/VirtualFeed.svelte | 2 +- src/lib/components/ui/EntityHeader.svelte | 28 +- src/lib/components/ui/Expandable.svelte | 3 +- src/lib/components/ui/layout/Shell.svelte | 2 +- src/routes/c/[name]/+page.svelte | 1 + src/routes/signup/[instance]/+page.svelte | 3 +- 11 files changed, 299 insertions(+), 252 deletions(-) diff --git a/src/lib/components/lemmy/SiteCard.svelte b/src/lib/components/lemmy/SiteCard.svelte index a09c141d..a1a4d741 100644 --- a/src/lib/components/lemmy/SiteCard.svelte +++ b/src/lib/components/lemmy/SiteCard.svelte @@ -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 { site: SiteView @@ -38,10 +44,7 @@ ]} > {#if site.site.banner} -
+
Site banner
{/if} - -

{site.site.name}

+
+ +

{site.site.name}

+
{#if taglines && taglines.length > 0} {/if} -
- - {#snippet title()} - - {$t('cards.site.about')} - - {/snippet} - -
- + + {$t('nav.menu.instance')} + + + + - {#if version} -
- - - {version} - -
- {/if} -
+ + {$t('cards.site.stats')} + +
+ + + +
-
- - {#snippet title()} - - {$t('cards.site.stats')} - - {/snippet} -
- - - -
-
- - {#if admins} -
- + + {$t('common.info')} + +
+ {#snippet title()} - {$t('cards.site.admins')} + {$t('cards.site.about')} {/snippet} - ({ - 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, - }))} - /> - - {/if} + +
+ -
- - {$t('routes.modlog.title')} - - • - - {$t('routes.legal.title')} - - • - - {$t('routes.instances')} - + {#if version} +
+ + + {version} + +
+ {/if} + + + {#if admins} + + {#snippet title()} + + {$t('cards.site.admins')} + + {/snippet} + ({ + 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, + }))} + /> + + {/if}
diff --git a/src/lib/components/lemmy/community/CommunityCard.svelte b/src/lib/components/lemmy/community/CommunityCard.svelte index bd2ad6b6..25dc27bc 100644 --- a/src/lib/components/lemmy/community/CommunityCard.svelte +++ b/src/lib/components/lemmy/community/CommunityCard.svelte @@ -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}
+ + + {$t('form.post.community')} + + {#if profile.current?.jwt} + {@const subscribed = profile.current.user?.follows.some( + i => i.community.id == community_view.community.id, + )} + + {/if} + {#if profile.current?.user && amMod(profile.current.user, community_view.community)} + + {/if} + + {#snippet target(attachment)} + {/snippet} - + + + {$t('cards.community.modlog')} + + {#if profile.current?.jwt} + {#if profile.current.user && amMod(profile.current.user, community_view.community)} + + + {$t('routes.moderation.feed')} + + {/if} + + block(community_view.community.id, !community_view.blocked)} + > + {#snippet prefix()} + + {/snippet} + {community_view.blocked + ? $t('cards.community.unblock') + : $t('cards.community.block')} + + {#if profile.current?.user} + blockInstance(community_view.community.instance_id)} + > + {#snippet prefix()} + + {/snippet} + {$t('cards.community.blockInstance')} + + {/if} + {#if profile.current?.user && isAdmin(profile.current.user)} + + 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()} + + {/snippet} + {$t('admin.purge')} + + {/if} + {/if} + + + {$t('cards.site.stats')} + -
-
- +
+ + + +
+ + + {$t('common.info')} + +
+ {#snippet title()} - + {$t('cards.site.about')} {/snippet} -
- - {#snippet title()} - - {$t('cards.site.stats')} - - {/snippet} -
- - -
-
- {#if moderators && moderators.length > 0} -
{#snippet title()} - + {$t('cards.community.moderators')} {/snippet} @@ -229,117 +356,5 @@ {/if}
-
- {#if profile.current?.jwt} - - {/if} - {#if profile.current?.user && amMod(profile.current.user, community_view.community)} - - {/if} - - {#snippet target(attachment)} - - {/snippet} - - - {$t('cards.community.modlog')} - - {#if profile.current?.jwt} - - block(community_view.community.id, !community_view.blocked)} - > - {#snippet prefix()} - - {/snippet} - {community_view.blocked - ? $t('cards.community.unblock') - : $t('cards.community.block')} - - {#if profile.current?.user} - - blockInstance(community_view.community.instance_id)} - > - {#snippet prefix()} - - {/snippet} - {$t('cards.community.blockInstance')} - - {/if} - {#if profile.current?.user && isAdmin(profile.current.user)} - - 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()} - - {/snippet} - {$t('admin.purge')} - - {/if} - {/if} - -
{/await} diff --git a/src/lib/components/lemmy/community/CommunityForm.svelte b/src/lib/components/lemmy/community/CommunityForm.svelte index 21778ffb..1d916135 100644 --- a/src/lib/components/lemmy/community/CommunityForm.svelte +++ b/src/lib/components/lemmy/community/CommunityForm.svelte @@ -164,11 +164,11 @@ />
diff --git a/src/lib/components/lemmy/community/CommunityHeader.svelte b/src/lib/components/lemmy/community/CommunityHeader.svelte index d8039c70..df3caec5 100644 --- a/src/lib/components/lemmy/community/CommunityHeader.svelte +++ b/src/lib/components/lemmy/community/CommunityHeader.svelte @@ -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() {/snippet} {#if moderators.length > 0} - + {#snippet title()} {$t('cards.community.moderators')}
@@ -114,7 +119,7 @@ />
{/if} -
+
{#if profile.current?.jwt} {#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', diff --git a/src/lib/components/lemmy/post/feed/VirtualFeed.svelte b/src/lib/components/lemmy/post/feed/VirtualFeed.svelte index c54aa135..61b0fa61 100644 --- a/src/lib/components/lemmy/post/feed/VirtualFeed.svelte +++ b/src/lib/components/lemmy/post/feed/VirtualFeed.svelte @@ -227,7 +227,7 @@ {/if} {/key} - {#if settings.infiniteScroll && browser} + {#if settings.infiniteScroll && browser && posts.length > 0} {#if error}
+
User banner
- {#if banner || avatar} + {#if banner}
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', + ]} />
@@ -91,7 +101,12 @@ {/if}
{#if stats.length > 0} -
+
{#each stats as stat}
@@ -117,6 +132,7 @@ {#if bio}
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 diff --git a/src/lib/components/ui/layout/Shell.svelte b/src/lib/components/ui/layout/Shell.svelte index f3269dcb..b642b214 100644 --- a/src/lib/components/ui/layout/Shell.svelte +++ b/src/lib/components/ui/layout/Shell.svelte @@ -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;', })}
diff --git a/src/routes/c/[name]/+page.svelte b/src/routes/c/[name]/+page.svelte index 5f89f483..c1c5f2ca 100644 --- a/src/routes/c/[name]/+page.svelte +++ b/src/routes/c/[name]/+page.svelte @@ -71,6 +71,7 @@ moderators={data.community.value.moderators} counts={data.community.value.community_view.counts} class="w-full relative" + compact="lg" />
{#snippet extended()} diff --git a/src/routes/signup/[instance]/+page.svelte b/src/routes/signup/[instance]/+page.svelte index 3531f509..27ad597e 100644 --- a/src/routes/signup/[instance]/+page.svelte +++ b/src/routes/signup/[instance]/+page.svelte @@ -157,6 +157,7 @@ class="flex flex-col gap-4 h-full w-full flex-2/3" onsubmit={preventDefault(submit)} > +