design: make compact posts even more compact

This commit is contained in:
Xylight committed 2024-09-15 14:11:02 -07:00
1 parent d0c29cd957
commit 9f1ad19391
9 files changed
+83 -92

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "photon-lemmy", "name": "photon-lemmy",
"version": "1.31.3", "version": "1.31.4",
"devDependencies": { "devDependencies": {
"@catdadcode/svelte-adapter-bun": "^0.5.7", "@catdadcode/svelte-adapter-bun": "^0.5.7",
"@dicebear/core": "^8.0.1", "@dicebear/core": "^8.0.1",
@@ -52,13 +52,4 @@
/> />
{$t('filter.view.compact')} {$t('filter.view.compact')}
</option> </option>
<option value="card">
<Icon
src={Clock}
size="16"
micro
class="text-slate-600 dark:text-zinc-400"
/>
{$t('filter.view.legacy')}
</option>
</Select> </Select>
+30 -24
View File
@@ -82,18 +82,16 @@
--> -->
<!-- svelte-ignore a11y-no-static-element-interactions --> <!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
<Material <!-- svelte-ignore a11y-no-noninteractive-tabindex -->
element="article" <div
color={view != 'card' ? 'none' : 'distinct'} class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none
class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none group group @container/post
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact' {$userSettings.leftAlign ? 'left-align' : ''}
? 'py-3 list-type compact-view' {view == 'compact' ? 'py-3 list-type compact' : ''}
: view == 'list' {view == 'list' ? 'py-5 list-type' : ''}
? 'py-5 list-type' {view == 'cozy' ? 'py-5 flex flex-col gap-2' : ''}
: 'py-5 flex flex-col gap-2'} {$$props.class}" {$$props.class ?? ''}"
id={post.post.id.toString()} id={post.post.id.toString()}
padding="none"
rounding={view == 'card' ? undefined : 'none'}
on:click={(e) => { on:click={(e) => {
onClick(e) onClick(e)
}} }}
@@ -153,8 +151,8 @@
bind:post={post.post} bind:post={post.post}
bind:type bind:type
class="{$userSettings.leftAlign class="{$userSettings.leftAlign
? 'mr-2' ? 'mr-3'
: 'ml-2'} flex-shrink no-list-margin" : 'ml-3'} flex-shrink no-list-margin"
style="grid-area: media;" style="grid-area: media;"
{view} {view}
/> />
@@ -191,27 +189,35 @@
group-focus:inset-y-0.5 group-focus:-inset-x-4 group-focus:sm:-inset-x-5 group-focus:opacity-100 group-focus:inset-y-0.5 group-focus:-inset-x-4 group-focus:sm:-inset-x-5 group-focus:opacity-100
duration-150" duration-150"
/> />
</Material> </div>
<style> <style>
:global(.list-type) { .list-type {
display: grid; display: grid;
grid-template-areas: var( grid-template-areas: 'meta media' 'title media' 'body media' 'embed embed' 'actions actions';
--template-areas, grid-template-columns: minmax(0, 1fr) auto;
'meta media' 'title media' 'body media' 'embed embed' 'actions actions'
);
width: 100%; width: 100%;
height: 100%; height: 100%;
grid-template-columns: var(--template-columns, 1fr auto);
} }
:global(.compact-view > *:not(.no-list-margin):not(:first-child)) { .list-type.left-align {
grid-template-areas: 'media meta' 'media title' 'media body' 'embed embed' 'actions actions';
grid-template-columns: auto minmax(0, 1fr);
}
.list-type.compact {
grid-template-areas: 'meta media' 'title media' 'body media' 'embed media' 'actions media';
}
.list-type.compact.left-align {
grid-template-areas: 'media meta' 'media title' 'media body' 'media embed' 'media actions';
}
:global(.compact > *:not(.no-list-margin):not(:first-child)) {
margin-top: 0.3rem; margin-top: 0.3rem;
} }
:global( :global(.list-type:not(.compact) > *:not(.no-list-margin):not(:first-child)) {
.list-type:not(.compact-view) > *:not(.no-list-margin):not(:first-child)
) {
margin-top: 0.5rem; margin-top: 0.5rem;
} }
</style> </style>
@@ -80,8 +80,8 @@
let localShare = false let localShare = false
$: buttonHeight = view == 'compact' ? 'h-[30px]' : 'h-8' $: buttonHeight = view == 'compact' ? 'h-7' : 'h-8'
$: buttonSquare = view == 'compact' ? 'w-[30px] h-[30px]' : 'w-8 h-8' $: buttonSquare = view == 'compact' ? 'w-7 h-7' : 'w-8 h-8'
</script> </script>
{#if editing} {#if editing}
+44 -35
View File
@@ -115,6 +115,7 @@
class="grid w-full meta {community class="grid w-full meta {community
? 'grid-rows-2' ? 'grid-rows-2'
: 'grid-rows-1'} text-xs min-w-0 max-w-full" : 'grid-rows-1'} text-xs min-w-0 max-w-full"
class:compact={view == 'compact'}
style={$$props.style ?? ''} style={$$props.style ?? ''}
> >
{#if showCommunity && community && subscribed} {#if showCommunity && community && subscribed}
@@ -126,7 +127,7 @@
> >
<Avatar <Avatar
url={community.icon} url={community.icon}
width={32} width={view == 'compact' ? 24 : 32}
alt={community.name} alt={community.name}
class="group-hover/community:ring-2 transition-all ring-offset-1 ring-primary-900 dark:ring-primary-100" class="group-hover/community:ring-2 transition-all ring-offset-1 ring-primary-900 dark:ring-primary-100"
/> />
@@ -145,42 +146,44 @@
<CommunityLink <CommunityLink
{community} {community}
style="grid-area: community;" style="grid-area: community;"
class="flex-shrink self-end" class="flex-shrink"
/> />
{/if} {/if}
<span {#if view != 'compact'}
class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 items-center self-start" <span
style="grid-area: stats;" class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 items-center self-start"
> style="grid-area: stats;"
{#if user} >
<address class="contents not-italic"> {#if user}
<UserLink avatarSize={20} {user} avatar={!showCommunity}> <address class="contents not-italic">
<svelte:fragment slot="badges"> <UserLink avatarSize={20} {user} avatar={!showCommunity}>
{#if badges.moderator} <svelte:fragment slot="badges">
<ShieldIcon filled width={14} class="text-green-500" /> {#if badges.moderator}
{/if} <ShieldIcon filled width={14} class="text-green-500" />
{#if badges.admin} {/if}
<ShieldIcon filled width={14} class="text-red-500" /> {#if badges.admin}
{/if} <ShieldIcon filled width={14} class="text-red-500" />
</svelte:fragment> {/if}
</UserLink> </svelte:fragment>
</address> </UserLink>
{/if} </address>
{#if published} {/if}
<RelativeDate date={published} class="flex-shrink-0" /> {#if published}
{/if} <RelativeDate date={published} class="flex-shrink-0" />
{#if edited} {/if}
<div {#if edited}
title={$t('post.meta.lastEdited', { <div
default: formatRelativeDate(publishedToDate(edited), { title={$t('post.meta.lastEdited', {
style: 'long', default: formatRelativeDate(publishedToDate(edited), {
}), style: 'long',
})} }),
> })}
<Icon src={Pencil} micro size="14" /> >
</div> <Icon src={Pencil} micro size="14" />
{/if} </div>
</span> {/if}
</span>
{/if}
<div <div
class="flex flex-row justify-end items-center self-center flex-wrap gap-2 [&>*]:flex-shrink-0 badges ml-2" class="flex flex-row justify-end items-center self-center flex-wrap gap-2 [&>*]:flex-shrink-0 badges ml-2"
style="grid-area: badges;" style="grid-area: badges;"
@@ -293,6 +296,12 @@
grid-template-columns: max-content minmax(0, auto) auto; grid-template-columns: max-content minmax(0, auto) auto;
} }
.meta.compact {
display: flex;
flex-direction: row;
align-items: start;
}
:global(.badge-tag-color) { :global(.badge-tag-color) {
background-color: var(--tag-color) !important; background-color: var(--tag-color) !important;
} }
@@ -23,14 +23,6 @@
class="flex flex-col list-none {$userSettings.view == 'card' class="flex flex-col list-none {$userSettings.view == 'card'
? 'gap-3 md:gap-4' ? 'gap-3 md:gap-4'
: 'divide-y'} divide-slate-200 dark:divide-zinc-800" : 'divide-y'} divide-slate-200 dark:divide-zinc-800"
style={$userSettings.leftAlign
? `--template-areas:
'media meta'
'media title'
'media body'
'embed embed'
'actions actions'; --template-columns: auto 1fr;`
: ``}
> >
{#if posts?.length == 0} {#if posts?.length == 0}
<div class="h-full grid place-items-center"> <div class="h-full grid place-items-center">
@@ -214,14 +214,6 @@
class="flex flex-col list-none {$userSettings.view == 'card' class="flex flex-col list-none {$userSettings.view == 'card'
? 'gap-3 md:gap-4' ? 'gap-3 md:gap-4'
: 'divide-y'} divide-slate-200 dark:divide-zinc-800" : 'divide-y'} divide-slate-200 dark:divide-zinc-800"
style={$userSettings.leftAlign
? `--template-areas:
'media meta'
'media title'
'media body'
'embed embed'
'actions actions'; --template-columns: auto 1fr;`
: ``}
> >
{#if posts?.length == 0} {#if posts?.length == 0}
<div class="h-full grid place-items-center"> <div class="h-full grid place-items-center">
@@ -31,7 +31,7 @@
color="distinct" color="distinct"
class="flex flex-col-reverse sm:flex-row class="flex flex-col-reverse sm:flex-row
overflow-hidden gap-4 embed-card z-0 relative overflow-hidden gap-4 embed-card z-0 relative
dark:border-t-zinc-800 border-opacity-80" dark:border-t-zinc-800 border-opacity-80 max-w-full"
rounding="xl" rounding="xl"
element="article" element="article"
> >
@@ -125,7 +125,7 @@
</PostLinkSources> </PostLinkSources>
</div> </div>
{:else} {:else}
<div class="flex items-center gap-1"> <div class="flex space-x-1">
<PostLinkSources {url}> <PostLinkSources {url}>
<Button <Button
color="ghost" color="ghost"
@@ -147,7 +147,7 @@
href={url} href={url}
target="_blank" target="_blank"
class="text-slate-900 dark:text-zinc-300 items-center class="text-slate-900 dark:text-zinc-300 items-center
text-xs overflow-hidden max-w-full block" text-xs overflow-hidden max-w-full block flex-shrink"
size="sm" size="sm"
color="ghost" color="ghost"
rounding="pill" rounding="pill"
@@ -70,8 +70,9 @@
/> />
{#if type != 'image'} {#if type != 'image'}
<div <div
class="absolute w-7 h-7 bottom-0 left-0 m-2 rounded-lg text-slate-800 dark:text-zinc-200 class="absolute w-8 h-8 bottom-0 left-0 m-1 rounded-xl text-slate-800 dark:text-zinc-200
backdrop-blur-sm bg-[#ffffff]/75 dark:bg-black/75 grid place-items-center" backdrop-blur-sm bg-slate-25/75 dark:bg-zinc-900/75 border border-slate-200/75 dark:border-zinc-700/75
grid place-items-center"
> >
<Icon src={type == 'iframe' ? VideoCamera : Link} micro size="16" /> <Icon src={type == 'iframe' ? VideoCamera : Link} micro size="16" />
</div> </div>