design: improve big card for community
This commit is contained in:
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>
|
||||||
@@ -320,6 +320,7 @@
|
|||||||
|
|
||||||
data.community = c
|
data.community = c
|
||||||
}}
|
}}
|
||||||
|
class="w-max"
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
|
|||||||
@@ -360,7 +360,7 @@
|
|||||||
{@const useAttachedUrl = settings.posts.titleOpensUrl && postUrl}
|
{@const useAttachedUrl = settings.posts.titleOpensUrl && postUrl}
|
||||||
<h3
|
<h3
|
||||||
class={[
|
class={[
|
||||||
'font-medium max-sm:mt-0! tracking-tight',
|
'font-medium max-sm:mt-0! font-display',
|
||||||
titleClass,
|
titleClass,
|
||||||
settings.markReadPosts && read && 'text-slate-600 dark:text-zinc-400',
|
settings.markReadPosts && read && 'text-slate-600 dark:text-zinc-400',
|
||||||
view == 'compact' ? 'text-base' : 'text-lg',
|
view == 'compact' ? 'text-base' : 'text-lg',
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
url: string | undefined
|
url: string | undefined
|
||||||
alt?: string
|
alt?: string
|
||||||
title?: string
|
title?: string
|
||||||
circle?: boolean
|
circle?: boolean | null
|
||||||
width: number
|
width: number
|
||||||
res?: number | undefined
|
res?: number | undefined
|
||||||
style?: string
|
style?: string
|
||||||
@@ -67,7 +67,8 @@
|
|||||||
{title}
|
{title}
|
||||||
class={[
|
class={[
|
||||||
'aspect-square object-cover overflow-hidden shrink-0 bg-slate-100 dark:bg-zinc-900',
|
'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,
|
clazz,
|
||||||
]}
|
]}
|
||||||
style="width: {width}px; height: {width}px; {style}"
|
style="width: {width}px; height: {width}px; {style}"
|
||||||
@@ -77,7 +78,7 @@
|
|||||||
style="width: {width}px; height: {width}px;"
|
style="width: {width}px; height: {width}px;"
|
||||||
class={[
|
class={[
|
||||||
'aspect-square object-cover overflow-hidden shrink-0',
|
'aspect-square object-cover overflow-hidden shrink-0',
|
||||||
circle ? 'rounded-full' : 'rounded-lg',
|
circle === true ? 'rounded-full' : circle === false ? 'rounded-lg' : '',
|
||||||
clazz,
|
clazz,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul class="space-y-0.5">
|
<ul>
|
||||||
{#if items}
|
{#if items}
|
||||||
{#each items as item, index (item)}
|
{#each items as item, index (item)}
|
||||||
<li
|
<li
|
||||||
@@ -50,6 +50,15 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<style>
|
<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) {
|
ul > :global(li) {
|
||||||
transition: background-color 0.1s;
|
transition: background-color 0.1s;
|
||||||
background-color: var(--color-white);
|
background-color: var(--color-white);
|
||||||
|
|||||||
@@ -87,14 +87,14 @@
|
|||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
backdrop-filter: blur(var(--blur-xl));
|
backdrop-filter: blur(var(--blur-xl));
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-color: var(--color-slate-200);
|
border-color: var(--color-slate-100);
|
||||||
border-top: none;
|
border-top: none;
|
||||||
background-color: var(--color-slate-100);
|
background-color: var(--color-slate-50);
|
||||||
|
|
||||||
@variant md {
|
@variant md {
|
||||||
border-left: none;
|
border-left: none;
|
||||||
border-right: none;
|
border-right: none;
|
||||||
background-color: --alpha(var(--color-slate-100) / 70%);
|
background-color: --alpha(var(--color-slate-50) / 70%);
|
||||||
}
|
}
|
||||||
|
|
||||||
@variant dark {
|
@variant dark {
|
||||||
@@ -150,9 +150,9 @@
|
|||||||
.shell-main {
|
.shell-main {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
grid-area: main;
|
grid-area: main;
|
||||||
background-color: var(--color-slate-50);
|
background-color: var(--color-slate-25);
|
||||||
border-left: 1px solid var(--color-slate-200);
|
border-left: 1px solid var(--color-slate-100);
|
||||||
border-right: 1px solid var(--color-slate-200);
|
border-right: 1px solid var(--color-slate-100);
|
||||||
padding-bottom: calc(var(--spacing) * 22);
|
padding-bottom: calc(var(--spacing) * 22);
|
||||||
|
|
||||||
@variant dark {
|
@variant dark {
|
||||||
@@ -171,7 +171,7 @@
|
|||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
background-color: var(--color-slate-100);
|
background-color: var(--color-slate-50);
|
||||||
z-index: 40;
|
z-index: 40;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@
|
|||||||
class={[
|
class={[
|
||||||
pageHeader &&
|
pageHeader &&
|
||||||
`w-[calc(100%+1.5rem)] sm:w-[calc(100%+3rem)]
|
`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
|
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-200 dark:border-zinc-900 margin z-0 mb-3 sm:mb-6`,
|
border-b border-slate-100 dark:border-zinc-900 font-display margin z-0 mb-3 sm:mb-6`,
|
||||||
]}
|
]}
|
||||||
{style}
|
{style}
|
||||||
aria-label={$t('aria.element.pageHeader')}
|
aria-label={$t('aria.element.pageHeader')}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="box-border w-5 h-full bg-white dark:peer-checked:bg-black rounded-full shadow-xs
|
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"
|
peer-checked:rtl:-translate-x-5 peer-checked:group-active:rtl:-translate-x-4"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,6 +49,6 @@
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
.transition {
|
.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>
|
</style>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
elevation = 'flat',
|
elevation = 'medium',
|
||||||
padding = 'md',
|
padding = 'md',
|
||||||
rounding = 'xl',
|
rounding = 'xl',
|
||||||
color = 'uniform',
|
color = 'uniform',
|
||||||
@@ -95,6 +95,16 @@
|
|||||||
background-color: var(--color-zinc-900);
|
background-color: var(--color-zinc-900);
|
||||||
border-color: var(--color-zinc-800);
|
border-color: var(--color-zinc-800);
|
||||||
border-top-color: var(--color-zinc-700);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { navigating, page } from '$app/state'
|
import { navigating, page } from '$app/state'
|
||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
import CommunityItem from '$lib/feature/community/CommunityItem.svelte'
|
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 Fixate from '$lib/ui/generic/Fixate.svelte'
|
||||||
import Skeleton from '$lib/ui/generic/Skeleton.svelte'
|
import Skeleton from '$lib/ui/generic/Skeleton.svelte'
|
||||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||||
@@ -51,7 +52,7 @@
|
|||||||
{$t('routes.search.top')}
|
{$t('routes.search.top')}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
<div
|
<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)}
|
{#each data.communities.slice(0, 3) as community, index (community.community.id)}
|
||||||
<div
|
<div
|
||||||
@@ -63,8 +64,8 @@
|
|||||||
y: 16,
|
y: 16,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Material color="uniform" padding="none" rounding="2xl">
|
<Material padding="none" rounding="none" class="rounded-3xl h-full">
|
||||||
<CommunityItem {community} showCounts={false} view="cozy" />
|
<CommunityItemBig {community} />
|
||||||
</Material>
|
</Material>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in new issue
Block a user