design: make compact mode more ocmpact

This commit is contained in:
Xylight committed 2024-07-17 10:24:42 -07:00
1 parent 260fd895e2
commit 9d96a3d639
5 files changed
+61 -26

No files matched your search

+11 -3
View File
@@ -86,7 +86,7 @@
color={view != 'card' ? 'none' : 'distinct'} color={view != 'card' ? 'none' : 'distinct'}
class="post relative max-w-full min-w-0 w-full group cursor-pointer class="post relative max-w-full min-w-0 w-full group cursor-pointer
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact' {view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
? 'py-4 list-type' ? 'py-3 list-type compact-view'
: view == 'list' : view == 'list'
? 'py-5 list-type' ? 'py-5 list-type'
: 'py-5 flex flex-col gap-2'} {$$props.class}" : 'py-5 flex flex-col gap-2'} {$$props.class}"
@@ -122,6 +122,7 @@
read={post.read} read={post.read}
style="grid-area: meta;" style="grid-area: meta;"
tags={tags?.tags} tags={tags?.tags}
{view}
> >
<slot name="badges" slot="badges" /> <slot name="badges" slot="badges" />
</PostMeta> </PostMeta>
@@ -147,6 +148,7 @@
? 'mr-2' ? 'mr-2'
: 'ml-2'} flex-shrink no-list-margin" : 'ml-2'} flex-shrink no-list-margin"
style="grid-area: media;" style="grid-area: media;"
{view}
/> />
{/if} {/if}
{/key} {/key}
@@ -154,7 +156,7 @@
<PostBody body={post.post.body} {view} style="grid-area: body" /> <PostBody body={post.post.body} {view} style="grid-area: body" />
{/if} {/if}
{#if actions} {#if actions}
<PostActions on:hide bind:post {type} style="grid-area: actions;" /> <PostActions on:hide bind:post {type} style="grid-area: actions;" {view} />
{:else if view == 'compact'} {:else if view == 'compact'}
<div class="flex flex-row items-center gap-2 text-sm"> <div class="flex flex-row items-center gap-2 text-sm">
<Badge> <Badge>
@@ -187,7 +189,13 @@
grid-template-columns: var(--template-columns, 1fr auto); grid-template-columns: var(--template-columns, 1fr auto);
} }
:global(.list-type > *:not(.no-list-margin):not(:first-child)) { :global(.compact-view > *:not(.no-list-margin):not(:first-child)) {
margin-top: 0.3rem;
}
:global(
.list-type:not(.compact-view) > *:not(.no-list-margin):not(:first-child)
) {
margin-top: 0.5rem; margin-top: 0.5rem;
} }
</style> </style>
@@ -44,7 +44,7 @@
} from '$lib/lemmy/contentview.js' } from '$lib/lemmy/contentview.js'
import { setSessionStorage } from '$lib/session.js' import { setSessionStorage } from '$lib/session.js'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { userSettings } from '$lib/settings.js' import { userSettings, type View } from '$lib/settings.js'
import { import {
Button, Button,
Menu, Menu,
@@ -66,6 +66,7 @@
export let post: PostView export let post: PostView
export let type: MediaType | undefined = undefined export let type: MediaType | undefined = undefined
export let view: View = 'cozy'
export let debug: boolean = false export let debug: boolean = false
const dispatcher = createEventDispatcher<{ edit: PostView; hide: boolean }>() const dispatcher = createEventDispatcher<{ edit: PostView; hide: boolean }>()
@@ -85,6 +86,9 @@
const stripSubdomain = (url: string) => const stripSubdomain = (url: string) =>
new URL(url).hostname.split('.').slice(-2).join('.') new URL(url).hostname.split('.').slice(-2).join('.')
$: buttonHeight = view == 'compact' ? 'h-[30px]' : 'h-8'
$: buttonSquare = view == 'compact' ? 'w-[30px] h-[30px]' : 'w-8 h-8'
</script> </script>
{#if fediseerData} {#if fediseerData}
@@ -130,7 +134,7 @@
{/if} {/if}
<div <div
class="flex flex-row gap-2 items-center !h-8 flex-shrink-0" class="flex flex-row gap-2 items-center flex-shrink-0 {buttonHeight}"
style={$$props.style ?? ''} style={$$props.style ?? ''}
> >
<PostVote <PostVote
@@ -144,7 +148,7 @@
<Button <Button
size="sm" size="sm"
href="/post/{getInstance()}/{post.post.id}" href="/post/{getInstance()}/{post.post.id}"
class="!text-inherit h-8 px-3" class="!text-inherit h-full px-3"
target={$userSettings.openLinksInNewTab ? '_blank' : ''} target={$userSettings.openLinksInNewTab ? '_blank' : ''}
title={$t('post.actions.comments')} title={$t('post.actions.comments')}
> >
@@ -162,14 +166,20 @@
<Button <Button
on:click={() => (debug = true)} on:click={() => (debug = true)}
title="Debug" title="Debug"
size="square-md" size="custom"
color="ghost" color="ghost"
class={buttonSquare}
> >
<Icon src={BugAnt} mini size="16" slot="prefix" /> <Icon src={BugAnt} mini size="16" slot="prefix" />
</Button> </Button>
{/if} {/if}
{#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))} {#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))}
<ModerationMenu bind:item={post} community={post.community} /> <ModerationMenu
size="custom"
class={buttonSquare}
bind:item={post}
community={post.community}
/>
{/if} {/if}
{#if $profile?.jwt} {#if $profile?.jwt}
@@ -180,7 +190,8 @@
post.saved = await save(post, !post.saved, $profile?.jwt) post.saved = await save(post, !post.saved, $profile?.jwt)
saving = false saving = false
}} }}
size="square-md" size="custom"
class={buttonSquare}
color="ghost" color="ghost"
loading={saving} loading={saving}
disabled={saving} disabled={saving}
@@ -197,7 +208,8 @@
{#if post.post.url && type == 'embed'} {#if post.post.url && type == 'embed'}
<Button <Button
size="square-md" size="custom"
class={buttonSquare}
color="ghost" color="ghost"
on:click={() => (mediaBias = !mediaBias)} on:click={() => (mediaBias = !mediaBias)}
title={$t('post.actions.more.mediaBias')} title={$t('post.actions.more.mediaBias')}
@@ -216,7 +228,8 @@
slot="target" slot="target"
title={$t('post.actions.more.label')} title={$t('post.actions.more.label')}
color="ghost" color="ghost"
size="square-md" size="custom"
class={buttonSquare}
> >
<Icon slot="prefix" src={EllipsisHorizontal} width={16} mini /> <Icon slot="prefix" src={EllipsisHorizontal} width={16} mini />
</Button> </Button>
+14 -5
View File
@@ -12,7 +12,7 @@
]) ])
export const parseTags = ( export const parseTags = (
title?: string title?: string,
): { tags: Tag[]; title?: string } => { ): { tags: Tag[]; title?: string } => {
if (!title) return { tags: [] } if (!title) return { tags: [] }
@@ -22,7 +22,7 @@
extracted.push( extracted.push(
textToTag.get(content) ?? { textToTag.get(content) ?? {
content: content, content: content,
} },
) )
return '' return ''
}) })
@@ -56,7 +56,7 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.js'
import Subscribe from '../../../../routes/communities/Subscribe.svelte' import Subscribe from '../../../../routes/communities/Subscribe.svelte'
import ShieldIcon from '../moderation/ShieldIcon.svelte' import ShieldIcon from '../moderation/ShieldIcon.svelte'
import { userSettings } from '$lib/settings' import { userSettings, type View } from '$lib/settings'
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import type { IconSource } from 'svelte-hero-icons' import type { IconSource } from 'svelte-hero-icons'
@@ -71,6 +71,8 @@
export let id: number | undefined = undefined export let id: number | undefined = undefined
export let read: boolean = false export let read: boolean = false
export let view: View = 'cozy'
// Badges // Badges
export let badges = { export let badges = {
nsfw: false, nsfw: false,
@@ -245,17 +247,24 @@
{#if title && id} {#if title && id}
<a <a
href="/post/{getInstance()}/{id}" href="/post/{getInstance()}/{id}"
class="inline text-lg hover:underline class="inline hover:underline
hover:text-primary-900 hover:dark:text-primary-100 transition-colors hover:text-primary-900 hover:dark:text-primary-100 transition-colors
{$userSettings.font == 'satoshi/nunito' {$userSettings.font == 'satoshi/nunito'
? 'font-display font-semibold' ? 'font-display font-semibold'
: 'font-medium'}" : 'font-medium'}"
class:text-slate-600={$userSettings.markReadPosts && read} class:text-slate-600={$userSettings.markReadPosts && read}
class:dark:text-zinc-400={$userSettings.markReadPosts && read} class:dark:text-zinc-400={$userSettings.markReadPosts && read}
class:text-base={view == 'compact'}
class:text-lg={view != 'compact'}
style="grid-area: title;" style="grid-area: title;"
data-sveltekit-preload-data="tap" data-sveltekit-preload-data="tap"
> >
<Markdown source={title} inline noStyle class="leading-[1.3]"></Markdown> <Markdown
source={title}
inline
noStyle
class={view == 'compact' ? '' : 'leading-[1.3]'}
></Markdown>
</a> </a>
{:else} {:else}
<div style="grid-area: title; margin: 0;"></div> <div style="grid-area: title; margin: 0;"></div>
@@ -5,7 +5,7 @@
export const shouldShowVoteColor = ( export const shouldShowVoteColor = (
vote: number, vote: number,
type: 'upvotes' | 'downvotes' type: 'upvotes' | 'downvotes',
): string => ): string =>
(vote == -1 && type == 'downvotes') || (vote == 1 && type == 'upvotes') (vote == -1 && type == 'downvotes') || (vote == 1 && type == 'upvotes')
? voteColor(vote) ? voteColor(vote)
@@ -57,7 +57,7 @@
<slot {vote} {score}> <slot {vote} {score}>
<div <div
class="{buttonColor.secondary} rounded-lg h-8 flex items-center [&>*]:p-2 class="{buttonColor.secondary} rounded-lg h-full font-medium flex items-center [&>*]:p-2
hover:bg-white hover:dark:bg-zinc-900 overflow-hidden transition-colors flex-shrink-0 hover:bg-white hover:dark:bg-zinc-900 overflow-hidden transition-colors flex-shrink-0
{loading ? 'animate-pulse opacity-75 pointer-events-none' : ''}" {loading ? 'animate-pulse opacity-75 pointer-events-none' : ''}"
> >
@@ -6,7 +6,7 @@
type MediaType, type MediaType,
} from '$lib/components/lemmy/post/helpers.js' } from '$lib/components/lemmy/post/helpers.js'
import { showImage } from '$lib/components/ui/ExpandableImage.svelte' import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
import { userSettings } from '$lib/settings.js' import { userSettings, type View } from '$lib/settings.js'
import { isImage } from '$lib/ui/image' import { isImage } from '$lib/ui/image'
import type { Post } from 'lemmy-js-client' import type { Post } from 'lemmy-js-client'
import { Material, Popover } from 'mono-svelte' import { Material, Popover } from 'mono-svelte'
@@ -14,6 +14,12 @@
export let post: Post export let post: Post
export let type: MediaType = 'none' export let type: MediaType = 'none'
export let view: View = 'cozy'
const thumbnailSize = (view: View) =>
view == 'compact' ? 'w-22 h-22 sm:w-28' : 'w-24 h-24 sm:w-32'
$: size = thumbnailSize(view)
</script> </script>
<!-- <!--
@@ -21,7 +27,7 @@
Thumbnails for compact and list view posts. Thumbnails for compact and list view posts.
--> -->
<div <div
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}" class="{size} relative group/media {$$props.class ?? ''}"
style={$$props.style ?? ''} style={$$props.style ?? ''}
> >
{#if post.alt_text} {#if post.alt_text}
@@ -48,7 +54,7 @@
href={postLink(post)} href={postLink(post)}
on:click={() => { on:click={() => {
if (type == 'image') { if (type == 'image') {
showImage(bestImageURL(post, false, 2048)) showImage(bestImageURL(post, false, -1))
} }
}} }}
role="button" role="button"
@@ -58,9 +64,8 @@
<img <img
src={optimizeImageURL(post.thumbnail_url || post.url || '', 196)} src={optimizeImageURL(post.thumbnail_url || post.url || '', 196)}
loading="lazy" loading="lazy"
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl h-24 w-24 sm:w-32 class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl
border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400 transition-colors {size}"
group-hover/media:dark:border-zinc-600 transition-colors"
alt={post.name} alt={post.name}
/> />
{#if type != 'image'} {#if type != 'image'}
@@ -73,10 +78,10 @@
{/if} {/if}
{:else} {:else}
<div <div
class="object-cover overflow-hidden bg-slate-50 dark:bg-zinc-900 rounded-xl h-24 w-24 sm:w-32 class="object-cover overflow-hidden bg-slate-50 dark:bg-zinc-900 rounded-xl
border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400 border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400
group-hover/media:dark:border-zinc-600 transition-colors text-slate-400 dark:text-zinc-600 grid group-hover/media:dark:border-zinc-600 transition-colors text-slate-400 dark:text-zinc-600 grid
place-items-center" place-items-center {size}"
> >
<Icon <Icon
src={type == 'embed' src={type == 'embed'