Merge pull request #340 from sevonj/compact-thumbnails
Compact mode thumbnails
This commit is contained in:
2 files changed
+30
-6
No files matched your search
@@ -108,6 +108,7 @@
|
|||||||
<PostMediaCompact
|
<PostMediaCompact
|
||||||
{view}
|
{view}
|
||||||
bind:post={post.post}
|
bind:post={post.post}
|
||||||
|
bind:type={type}
|
||||||
class="{$userSettings.leftAlign
|
class="{$userSettings.leftAlign
|
||||||
? 'mr-2'
|
? 'mr-2'
|
||||||
: 'ml-2'} flex-shrink no-list-margin"
|
: 'ml-2'} flex-shrink no-list-margin"
|
||||||
|
|||||||
@@ -3,31 +3,36 @@
|
|||||||
bestImageURL,
|
bestImageURL,
|
||||||
optimizeImageURL,
|
optimizeImageURL,
|
||||||
postLink,
|
postLink,
|
||||||
|
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 } 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 { DocumentText, Icon, Link, VideoCamera } from 'svelte-hero-icons';
|
||||||
|
|
||||||
export let view: 'card' | 'cozy' | 'list' | 'compact' = 'cozy'
|
export let view: 'card' | 'cozy' | 'list' | 'compact' = 'cozy'
|
||||||
export let post: Post
|
export let post: Post
|
||||||
|
export let type: MediaType = 'none'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if (view == 'list' || view == 'compact') && !post.embed_title && (post.thumbnail_url || isImage(post.url))}
|
{#if view == "compact" || (view == "list" && !post.embed_title && (post.thumbnail_url || isImage(post.url)))}
|
||||||
<div
|
<div
|
||||||
class="w-24 sm:w-32 h-24 group/media {$$props.class ?? ''}"
|
class="w-24 sm:w-32 h-24 group/media {$$props.class ?? ''}"
|
||||||
style={$$props.style ?? ''}
|
style={$$props.style ?? ''}
|
||||||
>
|
>
|
||||||
<svelte:element
|
<svelte:element
|
||||||
this={!$userSettings.expandImages ||
|
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
|
||||||
(post.thumbnail_url && !isImage(post.url))
|
|
||||||
? 'a'
|
|
||||||
: 'button'}
|
|
||||||
href={postLink(post)}
|
href={postLink(post)}
|
||||||
on:click={() => showImage(bestImageURL(post, false, 2048))}
|
on:click={() => {
|
||||||
|
if (type == "image") {
|
||||||
|
showImage(bestImageURL(post, false, 2048));
|
||||||
|
}
|
||||||
|
}}
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
|
{#if post.thumbnail_url || isImage(post.url)}
|
||||||
<img
|
<img
|
||||||
src={optimizeImageURL(post.thumbnail_url || post.url || '', 128)}
|
src={optimizeImageURL(post.thumbnail_url || post.url || '', 128)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
@@ -36,6 +41,24 @@
|
|||||||
group-hover/media:dark:border-zinc-600 transition-colors"
|
group-hover/media:dark:border-zinc-600 transition-colors"
|
||||||
alt={post.name}
|
alt={post.name}
|
||||||
/>
|
/>
|
||||||
|
{#if type != 'image'}
|
||||||
|
<div
|
||||||
|
class="relative w-7 h-7 bottom-8 left-1 rounded-lg text-slate-800 dark:text-zinc-200
|
||||||
|
backdrop-blur-sm bg-[#ffffff]/75 dark:bg-black/75 grid place-items-center"
|
||||||
|
>
|
||||||
|
<Icon src={type == 'iframe' ? VideoCamera : Link} mini size="16"/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{:else}
|
||||||
|
<div
|
||||||
|
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 text-slate-400 dark:text-zinc-600 grid
|
||||||
|
place-items-center"
|
||||||
|
>
|
||||||
|
<Icon src={type == 'embed' ? Link : DocumentText} solid size="32"/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</svelte:element>
|
</svelte:element>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
Reference in new issue
Block a user