design: redesign inbox (again)

This commit is contained in:
Xylight committed 2024-10-19 14:27:36 -07:00
1 parent 0d378ec248
commit 0d0681b687
13 files changed
+361 -281

No files matched your search

+1 -1
View File
@@ -149,7 +149,7 @@
{#each sliced as community, index (community.community.id)}
<div
class="px-6 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors @container
border-b border-slate-100 dark:border-zinc-800"
border-b border-slate-100 dark:border-zinc-900"
in:fly|global={{
duration: 1000,
easing: expoOut,
+72 -58
View File
@@ -23,6 +23,7 @@
import { t } from '$lib/translations'
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
import { expoOut } from 'svelte/easing'
export let data
@@ -97,67 +98,70 @@
{$t('routes.inbox.markAsRead')}
</Button>
</div>
<div
class="mt-4 mb-0 sticky z-30 mx-auto max-w-full flex gap-2 md:flex-row flex-col
items-center px-2 w-max"
style="top: max(1.5rem, {$contentPadding.top}px);"
slot="extended"
>
<Tabs
routes={[
{
href: '?type=all',
name: $t('filter.location.all'),
},
{
href: '?type=replies',
name: $t('filter.inbox.replies'),
},
{
href: '?type=mentions',
name: $t('filter.inbox.mentions'),
},
{
href: '/inbox/messages',
name: $t('filter.inbox.messages'),
},
]}
currentRoute={$page.url.search}
isSelected={(url, current, route, def) =>
$page.url.search == route ||
($page.url.pathname == route && $page.url.search == '') ||
$page.url.searchParams.toString().includes(route.slice(1)) ||
($page.url.search == '' && route == def)}
class="overflow-auto w-full"
buildUrl={(route, href) =>
href.includes('?')
? '?' + addSearchParam($page.url.searchParams, href).toString()
: `${href}${$page.url.search}`}
defaultRoute="?type=All"
/>
<Tabs
routes={[
{
href: '?unreadOnly=false',
name: $t('filter.location.all'),
},
{
href: '?unreadOnly=true',
name: $t('filter.unread'),
},
]}
isSelected={(url, current, route, def) =>
$page.url.searchParams.toString().includes(route.slice(1)) ||
($page.url.search == '' && route == def)}
buildUrl={(route, href) =>
'?' + addSearchParam($page.url.searchParams, href).toString()}
defaultRoute="?unreadOnly=true"
/>
</div>
</Header>
</div>
<div class="mt-4" />
<div
class="mt-4 mb-0 sticky z-30 mx-auto max-w-full flex gap-2 md:flex-row flex-col
items-center px-2"
style="top: max(1.5rem, {$contentPadding.top}px);"
class="flex flex-col list-none flex-1 h-full mt-4 divide-y divide-slate-200 dark:divide-zinc-900 *:py-4"
>
<Tabs
routes={[
{
href: '?type=All',
name: $t('filter.location.all'),
},
{
href: '?type=Replies',
name: $t('filter.inbox.replies'),
},
{
href: '?type=Mentions',
name: $t('filter.inbox.mentions'),
},
{
href: '/inbox/messages',
name: $t('filter.inbox.messages'),
},
]}
currentRoute={$page.url.search}
isSelected={(url, current, route, def) =>
$page.url.search == route ||
($page.url.pathname == route && $page.url.search == '') ||
$page.url.searchParams.toString().includes(route.slice(1)) ||
($page.url.search == '' && route == def)}
class="overflow-auto w-full"
buildUrl={(route, href) =>
href.includes('?')
? '?' + addSearchParam($page.url.searchParams, href).toString()
: `${href}${$page.url.search}`}
defaultRoute="?type=All"
/>
<Tabs
routes={[
{
href: '?unreadOnly=false',
name: $t('filter.location.all'),
},
{
href: '?unreadOnly=true',
name: $t('filter.unread'),
},
]}
isSelected={(url, current, route, def) =>
$page.url.searchParams.toString().includes(route.slice(1)) ||
($page.url.search == '' && route == def)}
buildUrl={(route, href) =>
'?' + addSearchParam($page.url.searchParams, href).toString()}
defaultRoute="?unreadOnly=true"
/>
</div>
<div class="flex flex-col gap-4 list-none flex-1 h-full mt-4">
{#if !data.data || (data.data?.length ?? 0) == 0}
<Placeholder
icon={Inbox}
@@ -165,9 +169,19 @@
description={$t('routes.inbox.empty.description')}
/>
{:else}
{#each data.data as item}
<div in:fly={{ duration: 500, y: -6, opacity: 0 }}>
<InboxItem {item} />
{#each data.data as item, index (item.id)}
<div
class="-mx-4 sm:-mx-6 px-4 sm:px-6
{item.read ? '' : 'bg-yellow-50/50 dark:bg-blue-500/5'}"
in:fly|global={{
duration: 1000,
y: 16,
opacity: 0,
easing: expoOut,
delay: index * 50,
}}
>
<InboxItem bind:item />
</div>
{/each}
{/if}
+108 -74
View File
@@ -11,6 +11,8 @@
Check,
Envelope,
Icon,
Eye,
EyeSlash,
} from 'svelte-hero-icons'
import { Material } from 'mono-svelte'
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
@@ -22,6 +24,9 @@
import PrivateMessage from '$lib/components/lemmy/inbox/PrivateMessage.svelte'
import PrivateMessageModal from '$lib/components/lemmy/modal/PrivateMessageModal.svelte'
import { t } from '$lib/translations'
import Expandable from '$lib/components/ui/Expandable.svelte'
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
export let item: InboxItem
@@ -68,91 +73,120 @@
<PrivateMessageModal bind:open={replying} user={item.item.creator} />
{/if}
<Material
class="flex flex-col max-w-full gap-4"
color="transparent"
rounding="xl"
>
<div class="meta w-full">
<div
class="rounded-full p-1 h-10 w-10 border border-slate-200 dark:border-zinc-800 grid place-items-center"
style="grid-area: a;"
>
<Icon
src={item.type == 'private_message'
? Envelope
: item.type == 'comment_reply'
? ChatBubbleOvalLeft
: AtSymbol}
size="24"
/>
</div>
<RelativeDate
class="text-xs text-slate-600 dark:text-zinc-400"
date={publishedToDate(item.published)}
style="grid-area: b;"
<Expandable open icon={false}>
<div class="flex flex-row gap-2 items-center w-full" slot="title">
<Avatar
url={item.creator.avatar}
circle={false}
width={28}
alt={item.creator.name}
/>
{#if item.type != 'private_message'}
<PostMeta title={item.item.post.name} id={item.item.post.id} />
{:else}
<PrivateMessage message={item.item} style="grid-area: title;" />
{/if}
<div class="flex flex-row gap-2 h-8" style="grid-area: actions;">
{#if !(item.type == 'private_message' && item.item.creator.id == $profile?.user?.local_user_view.person.id)}
<Button
class={item.read ? '!text-green-500' : ''}
size="square-md"
{loading}
disabled={loading}
on:click={() => markAsRead(!item.read)}
title={$t('post.actions.more.markRead')}
>
<Icon slot="prefix" src={Check} micro size="16" />
</Button>
{/if}
{#if item.type == 'private_message'}
{#if item.item.creator.id != $profile?.user?.local_user_view.person.id}
<Button size="square-md" on:click={() => (replying = !replying)}>
<Icon src={ArrowUturnLeft} size="16" micro />
</Button>
<!-- <div class="rounded-full p-1 border border-slate-200 dark:border-zinc-800">
<Icon
src={item.type == 'comment_reply'
? ChatBubbleOvalLeft
: item.type == 'private_message'
? Envelope
: item.type == 'person_mention'
? AtSymbol
: AtSymbol}
size="20"
mini
class="text-slate-600 dark:text-zinc-400"
/>
</div> -->
<div class="flex flex-col">
<div class="text-sm font-normal">
{#if item.type == 'comment_reply'}
{@html $t('routes.inbox.item.reply', {
// @ts-ignore
user: `<span class="font-medium">${item.creator.name}</span>`,
post: `<span class="font-medium">${item.item.post.name}</span>`,
})}
{:else if item.type == 'person_mention'}
{@html $t('routes.inbox.item.mention', {
// @ts-ignore
user: `<span class="font-medium">${item.creator.name}</span>`,
post: `<span class="font-medium">${item.item.post.name}</span>`,
})}
{:else if item.type == 'private_message'}
{@html $t('routes.inbox.item.message', {
// @ts-ignore
user: `<span class="font-medium">${item.item.creator.name}</span>`,
recipient: `<span class="font-medium">${item.item.recipient.name}</span>`,
})}
{/if}
{:else}
</div>
<div class="text-xs text-slate-600 dark:text-zinc-400">
<RelativeDate date={publishedToDate(item.published)} />
</div>
</div>
<div class="flex-1" />
<div class="flex gap-2 max-md:hidden flex-shrink-0">
<Button
color={item.read ? 'secondary' : 'primary'}
{loading}
disabled={loading}
on:click={(e) => {
e.stopPropagation()
markAsRead(!item.read)
}}
size="sm"
rounding="pill"
class="flex-shrink-0"
>
<Icon src={item.read ? EyeSlash : Eye} size="16" micro slot="prefix" />
{item.read
? $t('post.actions.more.markUnread')
: $t('post.actions.more.markRead')}
</Button>
{#if item.type == 'comment_reply' || item.type == 'person_mention'}
<Button
title={$t('common.jump')}
href="/comment/{item.item.comment.id}"
size="square-md"
size="sm"
rounding="pill"
class="flex-shrink-0"
>
<Icon src={ArrowUturnUp} micro size="16" />
{$t('common.jump')}
</Button>
{/if}
</div>
</div>
<div class="flex flex-col">
{#if item.type != 'private_message' && $profile?.user && item.item.post.creator_id != $profile.user.local_user_view.person.id}
<div class="flex flex-row text-xs items-center gap-2">
<div
class="border-t w-8 rounded-tl h-2 border-l ml-2 border-zinc-700"
/>
<div>
<UserLink
avatar
avatarSize={16}
user={$profile.user.local_user_view.person}
/>
</div>
</div>
{/if}
{#if item.type != 'private_message'}
<Comment
postId={item.item.post.id}
node={{ children: [], comment_view: item.item, depth: 1 }}
replying={false}
class="!p-0"
/>
<div slot="extended" class="flex gap-2 w-full md:hidden">
<Button
color={item.read ? 'secondary' : 'primary'}
{loading}
disabled={loading}
on:click={(e) => {
e.stopPropagation()
markAsRead(!item.read)
}}
size="sm"
rounding="pill"
>
<Icon src={item.read ? EyeSlash : Eye} size="16" micro slot="prefix" />
{$t('routes.inbox.item.markRead')}
</Button>
{#if item.type == 'comment_reply' || item.type == 'person_mention'}
<Button href="/comment/{item.item.comment.id}" size="sm" rounding="pill">
{$t('common.jump')}
</Button>
{/if}
</div>
</Material>
<svelte:fragment slot="content">
{#if item.type == 'comment_reply' || item.type == 'person_mention'}
<CommentItem
comment={item.item}
community={false}
view="cozy"
meta={false}
class="pt-0 pb-0"
/>
{:else}
<PrivateMessage message={item.item} meta={false} />
{/if}
</svelte:fragment>
</Expandable>
<style>
.meta {