design: improve big card for community

This commit is contained in:
Xylight committed 2025-10-17 19:33:34 -07:00
1 parent bf0046a9b0
commit 3b42fb61f9
10 files changed
+232 -20

No files matched your search

@@ -0,0 +1,190 @@
<script lang="ts">
import { client } from '$lib/api/client.svelte'
import type { CommunityView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { t } from '$lib/app/i18n'
import { communityLink } from '$lib/app/util.svelte'
import Avatar from '$lib/ui/generic/Avatar.svelte'
import Blobs from '$lib/ui/generic/Blobs.svelte'
import { Button, modal } from 'mono-svelte'
import type { Snippet } from 'svelte'
import {
Check,
ExclamationTriangle,
Icon,
InformationCircle,
MapPin,
NoSymbol,
Plus,
Trash,
} from 'svelte-hero-icons/dist'
import Subscribe from '../../../routes/communities/Subscribe.svelte'
import { optimizeImageURL } from '../post'
import { addSubscription } from '../user'
import CommunityCard from './CommunityCard.svelte'
interface Props {
community: CommunityView
resolveObject?: boolean
children?: Snippet
}
let { community = $bindable(), resolveObject, children }: Props = $props()
</script>
{#snippet communityInfo()}
<CommunityCard community_view={community} />
{/snippet}
<div
class={[
'flex flex-col items-start gap-2 p-4 h-full cursor-pointer',
'rounded-[inherit] overflow-hidden hover:bg-slate-50 hover:dark:bg-zinc-925 relative z-0 transition-colors',
]}
>
<a
href={communityLink(community.community)}
aria-label={$t('aria.postDecor.openLink')}
class="absolute inset-0 z-10"
></a>
<div class="-m-4 mask-b-from-0 relative h-24">
{#if community.community.banner}
<img
src={optimizeImageURL(community.community.banner, 512)}
alt=""
class="object-cover min-h-full"
/>
{:else if community.community.icon}
<img
src={community.community.icon}
alt=""
class="object-cover blur-3xl"
/>
{:else}
<div class="scale-200">
<Blobs seed={community.community.name} />
</div>
{/if}
</div>
<div class="flex flex-row justify-between w-full items-start">
<header class="flex-1 flex flex-col group">
<h3
class="font-medium overflow-hidden text-ellipsis leading-5 text-xl font-display"
>
{community.community.title}
</h3>
<p class="text-sm text-slate-600 dark:text-zinc-400">
{new URL(community.community.actor_id).hostname}
</p>
</header>
<Avatar
url={community.community.icon}
alt={community.community.title}
width={48}
circle={null}
class="rounded-xl"
/>
</div>
{#if community.community.deleted}
<Icon
src={Trash}
class="text-red-500 inline"
micro
size="14"
title={$t('post.badges.deleted')}
/>
{/if}
{#if community.community.nsfw}
<Icon
src={ExclamationTriangle}
class="text-red-500 inline"
micro
size="14"
title={$t('post.badges.nsfw')}
/>
{/if}
{#if community.banned_from_community}
<Icon
src={NoSymbol}
class="text-red-500 inline"
micro
size="14"
title={$t('comment.banned')}
/>
{/if}
{#if community.community.visibility == 'LocalOnly'}
<Icon
src={MapPin}
class="text-green-500 inline"
micro
size="14"
title={$t('routes.admin.config.listingType.local')}
/>
{/if}
<div class="flex gap-2 items-center justify-end w-full z-30 mt-auto">
<Button
rounding="xl"
color="ghost"
onclick={() =>
modal({ title: $t('form.post.community'), snippet: communityInfo })}
aria-label={$t('common.info')}
size="square-md"
>
<Icon src={InformationCircle} size="16" mini />
</Button>
<Subscribe {community}>
{#snippet children({ subscribe, subscribing })}
{@const subscribed =
community.subscribed == 'Subscribed' ||
community.subscribed == 'Pending'}
<Button
disabled={subscribing || !profile.current?.jwt}
loading={subscribing}
onclick={async () => {
const object =
resolveObject &&
(await client().resolveObject({
q: community.community.actor_id,
}))
const res = object
? await subscribe(object.community?.community.id)
: await subscribe()
if (res) {
const newSubscribed =
res.community_view.subscribed != 'NotSubscribed'
? 'Subscribed'
: 'NotSubscribed'
community.subscribed = newSubscribed
addSubscription(
community.community,
newSubscribed == 'Subscribed',
)
}
}}
title={subscribed
? $t('cards.community.subscribed')
: $t('cards.community.subscribe')}
color={subscribed ? 'secondary' : 'primary'}
class={[subscribed && 'text-slate-600 dark:text-zinc-400']}
icon={subscribed ? Check : Plus}
>
<span class={['@md:block']}>
{#if subscribed}
{$t('cards.community.subscribed')}
{:else}
{$t('cards.community.subscribe')}
{/if}
</span>
</Button>
{/snippet}
</Subscribe>
</div>
{#if children}
<div class="flex flex-row gap-2 items-center">
{@render children?.()}
</div>
{/if}
</div>
+1
View File
@@ -320,6 +320,7 @@
data.community = c
}}
class="w-max"
/>
{:else}
<div class="flex flex-col gap-1">
+1 -1
View File
@@ -360,7 +360,7 @@
{@const useAttachedUrl = settings.posts.titleOpensUrl && postUrl}
<h3
class={[
'font-medium max-sm:mt-0! tracking-tight',
'font-medium max-sm:mt-0! font-display',
titleClass,
settings.markReadPosts && read && 'text-slate-600 dark:text-zinc-400',
view == 'compact' ? 'text-base' : 'text-lg',
+4 -3
View File
@@ -32,7 +32,7 @@
url: string | undefined
alt?: string
title?: string
circle?: boolean
circle?: boolean | null
width: number
res?: number | undefined
style?: string
@@ -67,7 +67,8 @@
{title}
class={[
'aspect-square object-cover overflow-hidden shrink-0 bg-slate-100 dark:bg-zinc-900',
circle ? 'rounded-full' : 'rounded-lg',
circle === true ? 'rounded-full' : circle === false ? 'rounded-lg' : '',
clazz,
]}
style="width: {width}px; height: {width}px; {style}"
@@ -77,7 +78,7 @@
style="width: {width}px; height: {width}px;"
class={[
'aspect-square object-cover overflow-hidden shrink-0',
circle ? 'rounded-full' : 'rounded-lg',
circle === true ? 'rounded-full' : circle === false ? 'rounded-lg' : '',
clazz,
]}
>
+10 -1
View File
@@ -29,7 +29,7 @@
}: Props = $props()
</script>
<ul class="space-y-0.5">
<ul>
{#if items}
{#each items as item, index (item)}
<li
@@ -50,6 +50,15 @@
</ul>
<style>
@reference '../../../app.css';
ul {
:global {
:where(& > :not(:last-child)) {
margin-block-start: calc(calc(var(--spacing) * 0.75));
margin-block-end: calc(calc(var(--spacing) * 0.75));
}
}
}
ul > :global(li) {
transition: background-color 0.1s;
background-color: var(--color-white);
+7 -7
View File
@@ -87,14 +87,14 @@
pointer-events: auto;
backdrop-filter: blur(var(--blur-xl));
border-width: 1px;
border-color: var(--color-slate-200);
border-color: var(--color-slate-100);
border-top: none;
background-color: var(--color-slate-100);
background-color: var(--color-slate-50);
@variant md {
border-left: none;
border-right: none;
background-color: --alpha(var(--color-slate-100) / 70%);
background-color: --alpha(var(--color-slate-50) / 70%);
}
@variant dark {
@@ -150,9 +150,9 @@
.shell-main {
width: 100%;
grid-area: main;
background-color: var(--color-slate-50);
border-left: 1px solid var(--color-slate-200);
border-right: 1px solid var(--color-slate-200);
background-color: var(--color-slate-25);
border-left: 1px solid var(--color-slate-100);
border-right: 1px solid var(--color-slate-100);
padding-bottom: calc(var(--spacing) * 22);
@variant dark {
@@ -171,7 +171,7 @@
position: sticky;
top: 0;
left: 0;
background-color: var(--color-slate-100);
background-color: var(--color-slate-50);
z-index: 40;
width: 100%;
+2 -2
View File
@@ -31,8 +31,8 @@
class={[
pageHeader &&
`w-[calc(100%+1.5rem)] sm:w-[calc(100%+3rem)]
bg-slate-100 dark:bg-zinc-950 -mx-3 sm:-mx-6 sm:px-6 sm:pb-6 px-4 pb-4 -mt-64 pt-64
border-b border-slate-200 dark:border-zinc-900 margin z-0 mb-3 sm:mb-6`,
bg-slate-50 dark:bg-zinc-950 -mx-3 sm:-mx-6 sm:px-6 sm:pb-6 px-4 pb-4 -mt-64 pt-64
border-b border-slate-100 dark:border-zinc-900 font-display margin z-0 mb-3 sm:mb-6`,
]}
{style}
aria-label={$t('aria.element.pageHeader')}
+2 -2
View File
@@ -33,7 +33,7 @@
/>
<div
class="box-border w-5 h-full bg-white dark:peer-checked:bg-black rounded-full shadow-xs
group-active:w-6 transition peer-checked:translate-x-5 peer-checked:group-active:translate-x-4
group-active:w-5.5 transition peer-checked:translate-x-5 peer-checked:group-active:translate-x-4.5
peer-checked:rtl:-translate-x-5 peer-checked:group-active:rtl:-translate-x-4"
></div>
</div>
@@ -49,6 +49,6 @@
<style>
.transition {
transition: all 500ms cubic-bezier(0.075, 0.82, 0.165, 1);
transition: all 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
</style>
+11 -1
View File
@@ -53,7 +53,7 @@
}
let {
elevation = 'flat',
elevation = 'medium',
padding = 'md',
rounding = 'xl',
color = 'uniform',
@@ -95,6 +95,16 @@
background-color: var(--color-zinc-900);
border-color: var(--color-zinc-800);
border-top-color: var(--color-zinc-700);
@variant hover {
@variant dark {
background-color: var(--color-zinc-925);
}
}
}
@variant hover {
background-color: var(--color-slate-100);
}
}
+4 -3
View File
@@ -2,6 +2,7 @@
import { navigating, page } from '$app/state'
import { t } from '$lib/app/i18n'
import CommunityItem from '$lib/feature/community/CommunityItem.svelte'
import CommunityItemBig from '$lib/feature/community/CommunityItemBig.svelte'
import Fixate from '$lib/ui/generic/Fixate.svelte'
import Skeleton from '$lib/ui/generic/Skeleton.svelte'
import Placeholder from '$lib/ui/info/Placeholder.svelte'
@@ -51,7 +52,7 @@
{$t('routes.search.top')}
</EndPlaceholder>
<div
class="grid md:grid-cols-2 lg:grid-cols-3 gap-4 items-center mb-6 border-0!"
class="grid md:grid-cols-2 xl:grid-cols-3 gap-4 items-center border-0!"
>
{#each data.communities.slice(0, 3) as community, index (community.community.id)}
<div
@@ -63,8 +64,8 @@
y: 16,
}}
>
<Material color="uniform" padding="none" rounding="2xl">
<CommunityItem {community} showCounts={false} view="cozy" />
<Material padding="none" rounding="none" class="rounded-3xl h-full">
<CommunityItemBig {community} />
</Material>
</div>
{/each}