From 9d96a3d639196a3934522b8c3416d8af8d6623fb Mon Sep 17 00:00:00 2001 From: Xylight Date: Wed, 17 Jul 2024 10:24:42 -0700 Subject: [PATCH] design: make compact mode more ocmpact --- src/lib/components/lemmy/post/Post.svelte | 14 +++++++-- .../components/lemmy/post/PostActions.svelte | 29 ++++++++++++++----- src/lib/components/lemmy/post/PostMeta.svelte | 19 ++++++++---- src/lib/components/lemmy/post/PostVote.svelte | 4 +-- .../lemmy/post/media/PostMediaCompact.svelte | 21 +++++++++----- 5 files changed, 61 insertions(+), 26 deletions(-) diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte index 9ec09608..5534cebb 100644 --- a/src/lib/components/lemmy/post/Post.svelte +++ b/src/lib/components/lemmy/post/Post.svelte @@ -86,7 +86,7 @@ color={view != 'card' ? 'none' : 'distinct'} class="post relative max-w-full min-w-0 w-full group cursor-pointer {view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact' - ? 'py-4 list-type' + ? 'py-3 list-type compact-view' : view == 'list' ? 'py-5 list-type' : 'py-5 flex flex-col gap-2'} {$$props.class}" @@ -122,6 +122,7 @@ read={post.read} style="grid-area: meta;" tags={tags?.tags} + {view} > @@ -147,6 +148,7 @@ ? 'mr-2' : 'ml-2'} flex-shrink no-list-margin" style="grid-area: media;" + {view} /> {/if} {/key} @@ -154,7 +156,7 @@ {/if} {#if actions} - + {:else if view == 'compact'}
@@ -187,7 +189,13 @@ 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; } diff --git a/src/lib/components/lemmy/post/PostActions.svelte b/src/lib/components/lemmy/post/PostActions.svelte index 259d92a4..f5568e0c 100644 --- a/src/lib/components/lemmy/post/PostActions.svelte +++ b/src/lib/components/lemmy/post/PostActions.svelte @@ -44,7 +44,7 @@ } from '$lib/lemmy/contentview.js' import { setSessionStorage } from '$lib/session.js' import { goto } from '$app/navigation' - import { userSettings } from '$lib/settings.js' + import { userSettings, type View } from '$lib/settings.js' import { Button, Menu, @@ -66,6 +66,7 @@ export let post: PostView export let type: MediaType | undefined = undefined + export let view: View = 'cozy' export let debug: boolean = false const dispatcher = createEventDispatcher<{ edit: PostView; hide: boolean }>() @@ -85,6 +86,9 @@ const stripSubdomain = (url: string) => 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' {#if fediseerData} @@ -130,7 +134,7 @@ {/if}
@@ -162,14 +166,20 @@ {/if} {#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))} - + {/if} {#if $profile?.jwt} @@ -180,7 +190,8 @@ post.saved = await save(post, !post.saved, $profile?.jwt) saving = false }} - size="square-md" + size="custom" + class={buttonSquare} color="ghost" loading={saving} disabled={saving} @@ -197,7 +208,8 @@ {#if post.post.url && type == 'embed'} diff --git a/src/lib/components/lemmy/post/PostMeta.svelte b/src/lib/components/lemmy/post/PostMeta.svelte index 5403b10e..622eb3fd 100644 --- a/src/lib/components/lemmy/post/PostMeta.svelte +++ b/src/lib/components/lemmy/post/PostMeta.svelte @@ -12,7 +12,7 @@ ]) export const parseTags = ( - title?: string + title?: string, ): { tags: Tag[]; title?: string } => { if (!title) return { tags: [] } @@ -22,7 +22,7 @@ extracted.push( textToTag.get(content) ?? { content: content, - } + }, ) return '' }) @@ -56,7 +56,7 @@ import { profile } from '$lib/auth.js' import Subscribe from '../../../../routes/communities/Subscribe.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 { t } from '$lib/translations' import type { IconSource } from 'svelte-hero-icons' @@ -71,6 +71,8 @@ export let id: number | undefined = undefined export let read: boolean = false + export let view: View = 'cozy' + // Badges export let badges = { nsfw: false, @@ -245,17 +247,24 @@ {#if title && id} - + {:else}
diff --git a/src/lib/components/lemmy/post/PostVote.svelte b/src/lib/components/lemmy/post/PostVote.svelte index 38048d95..3a7377f3 100644 --- a/src/lib/components/lemmy/post/PostVote.svelte +++ b/src/lib/components/lemmy/post/PostVote.svelte @@ -5,7 +5,7 @@ export const shouldShowVoteColor = ( vote: number, - type: 'upvotes' | 'downvotes' + type: 'upvotes' | 'downvotes', ): string => (vote == -1 && type == 'downvotes') || (vote == 1 && type == 'upvotes') ? voteColor(vote) @@ -57,7 +57,7 @@
*]:p-2 hover:bg-white hover:dark:bg-zinc-900 overflow-hidden transition-colors flex-shrink-0 {loading ? 'animate-pulse opacity-75 pointer-events-none' : ''}" > diff --git a/src/lib/components/lemmy/post/media/PostMediaCompact.svelte b/src/lib/components/lemmy/post/media/PostMediaCompact.svelte index 14bfafad..fa87a6aa 100644 --- a/src/lib/components/lemmy/post/media/PostMediaCompact.svelte +++ b/src/lib/components/lemmy/post/media/PostMediaCompact.svelte @@ -6,7 +6,7 @@ type MediaType, } from '$lib/components/lemmy/post/helpers.js' 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 type { Post } from 'lemmy-js-client' import { Material, Popover } from 'mono-svelte' @@ -14,6 +14,12 @@ export let post: Post 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)
{#if post.alt_text} @@ -48,7 +54,7 @@ href={postLink(post)} on:click={() => { if (type == 'image') { - showImage(bestImageURL(post, false, 2048)) + showImage(bestImageURL(post, false, -1)) } }} role="button" @@ -58,9 +64,8 @@ {post.name} {#if type != 'image'} @@ -73,10 +78,10 @@ {/if} {:else}