design: make compact mode more ocmpact
This commit is contained in:
1 parent
260fd895e2
commit
9d96a3d639
5 files changed
+61
-26
No files matched your search
@@ -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}
|
||||
>
|
||||
<slot name="badges" slot="badges" />
|
||||
</PostMeta>
|
||||
@@ -147,6 +148,7 @@
|
||||
? 'mr-2'
|
||||
: 'ml-2'} flex-shrink no-list-margin"
|
||||
style="grid-area: media;"
|
||||
{view}
|
||||
/>
|
||||
{/if}
|
||||
{/key}
|
||||
@@ -154,7 +156,7 @@
|
||||
<PostBody body={post.post.body} {view} style="grid-area: body" />
|
||||
{/if}
|
||||
{#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'}
|
||||
<div class="flex flex-row items-center gap-2 text-sm">
|
||||
<Badge>
|
||||
@@ -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;
|
||||
}
|
||||
</style>
|
||||
@@ -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'
|
||||
</script>
|
||||
|
||||
{#if fediseerData}
|
||||
@@ -130,7 +134,7 @@
|
||||
{/if}
|
||||
|
||||
<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 ?? ''}
|
||||
>
|
||||
<PostVote
|
||||
@@ -144,7 +148,7 @@
|
||||
<Button
|
||||
size="sm"
|
||||
href="/post/{getInstance()}/{post.post.id}"
|
||||
class="!text-inherit h-8 px-3"
|
||||
class="!text-inherit h-full px-3"
|
||||
target={$userSettings.openLinksInNewTab ? '_blank' : ''}
|
||||
title={$t('post.actions.comments')}
|
||||
>
|
||||
@@ -162,14 +166,20 @@
|
||||
<Button
|
||||
on:click={() => (debug = true)}
|
||||
title="Debug"
|
||||
size="square-md"
|
||||
size="custom"
|
||||
color="ghost"
|
||||
class={buttonSquare}
|
||||
>
|
||||
<Icon src={BugAnt} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
{/if}
|
||||
{#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 $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'}
|
||||
<Button
|
||||
size="square-md"
|
||||
size="custom"
|
||||
class={buttonSquare}
|
||||
color="ghost"
|
||||
on:click={() => (mediaBias = !mediaBias)}
|
||||
title={$t('post.actions.more.mediaBias')}
|
||||
@@ -216,7 +228,8 @@
|
||||
slot="target"
|
||||
title={$t('post.actions.more.label')}
|
||||
color="ghost"
|
||||
size="square-md"
|
||||
size="custom"
|
||||
class={buttonSquare}
|
||||
>
|
||||
<Icon slot="prefix" src={EllipsisHorizontal} width={16} mini />
|
||||
</Button>
|
||||
|
||||
@@ -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}
|
||||
<a
|
||||
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
|
||||
{$userSettings.font == 'satoshi/nunito'
|
||||
? 'font-display font-semibold'
|
||||
: 'font-medium'}"
|
||||
class:text-slate-600={$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;"
|
||||
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>
|
||||
{:else}
|
||||
<div style="grid-area: title; margin: 0;"></div>
|
||||
|
||||
@@ -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 @@
|
||||
|
||||
<slot {vote} {score}>
|
||||
<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
|
||||
{loading ? 'animate-pulse opacity-75 pointer-events-none' : ''}"
|
||||
>
|
||||
|
||||
@@ -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)
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@@ -21,7 +27,7 @@
|
||||
Thumbnails for compact and list view posts.
|
||||
-->
|
||||
<div
|
||||
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
|
||||
class="{size} relative group/media {$$props.class ?? ''}"
|
||||
style={$$props.style ?? ''}
|
||||
>
|
||||
{#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 @@
|
||||
<img
|
||||
src={optimizeImageURL(post.thumbnail_url || post.url || '', 196)}
|
||||
loading="lazy"
|
||||
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl h-24 w-24 sm:w-32
|
||||
border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400
|
||||
group-hover/media:dark:border-zinc-600 transition-colors"
|
||||
class="object-cover overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl
|
||||
transition-colors {size}"
|
||||
alt={post.name}
|
||||
/>
|
||||
{#if type != 'image'}
|
||||
@@ -73,10 +78,10 @@
|
||||
{/if}
|
||||
{:else}
|
||||
<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
|
||||
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
|
||||
src={type == 'embed'
|
||||
|
||||
Reference in new issue
Block a user