1 parent
2902f30327
commit
e259ed4582
7 files changed
+142
-47
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<slot {...$$restProps} />
|
||||||
@@ -8,6 +8,9 @@
|
|||||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||||
import { Material, toast } from 'mono-svelte'
|
import { Material, toast } from 'mono-svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
|
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
|
||||||
|
import { bestImageURL, postLink } from '$lib/components/lemmy/post/helpers.js'
|
||||||
|
import Empty from '$lib/components/helper/Empty.svelte'
|
||||||
|
|
||||||
export let post: PostView
|
export let post: PostView
|
||||||
export let actions: boolean = true
|
export let actions: boolean = true
|
||||||
@@ -54,36 +57,42 @@
|
|||||||
{#if !$userSettings.showCompactPosts}
|
{#if !$userSettings.showCompactPosts}
|
||||||
{#if isImage(post.post.url)}
|
{#if isImage(post.post.url)}
|
||||||
<!--disabled preloads here since most people will hover over every image while scrolling-->
|
<!--disabled preloads here since most people will hover over every image while scrolling-->
|
||||||
<a
|
<svelte:component
|
||||||
href="/post/{getInstance()}/{post.post.id}"
|
this={$userSettings.expandImages ? ExpandableImage : Empty}
|
||||||
class="self-start overflow-hidden z-10 relative bg-slate-200 dark:bg-zinc-800 rounded-md max-w-full"
|
url={bestImageURL(post.post, false, 2048)}
|
||||||
data-sveltekit-preload-data="off"
|
|
||||||
aria-label={post.post.name}
|
|
||||||
>
|
>
|
||||||
<picture
|
<svelte:element
|
||||||
class="rounded-md overflow-hidden max-h-[min(50vh,500px)] w-full max-w-full"
|
this={$userSettings.expandImages ? 'div' : 'a'}
|
||||||
|
href={postLink(post.post)}
|
||||||
|
class="self-start overflow-hidden z-10 relative bg-slate-200 dark:bg-zinc-800 rounded-md max-w-full"
|
||||||
|
data-sveltekit-preload-data="off"
|
||||||
|
aria-label={post.post.name}
|
||||||
>
|
>
|
||||||
<source
|
<picture
|
||||||
srcset="{post.post.url}?thumbnail=256&format=webp"
|
class="rounded-md overflow-hidden max-h-[min(50vh,500px)] w-full max-w-full"
|
||||||
media="(max-width: 256px)"
|
>
|
||||||
/>
|
<source
|
||||||
<source
|
srcset={bestImageURL(post.post, false, 512)}
|
||||||
srcset="{post.post.url}?thumbnail=512&format=webp"
|
media="(max-width: 256px)"
|
||||||
media="(max-width: 512px)"
|
/>
|
||||||
/>
|
<source
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
srcset={bestImageURL(post.post, false, 512)}
|
||||||
<img
|
media="(max-width: 512px)"
|
||||||
src="{post.post.url}?thumbnail=512&format=webp"
|
/>
|
||||||
loading="lazy"
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
class="max-w-full object-cover rounded-md max-h-[80vh] h-auto z-30 opacity-0 transition-opacity duration-300"
|
<img
|
||||||
class:opacity-100={loaded}
|
src={bestImageURL(post.post, false, 1024)}
|
||||||
width={512}
|
loading="lazy"
|
||||||
height={300}
|
class="max-w-full object-cover rounded-md max-h-[80vh] h-auto z-30 opacity-0 transition-opacity duration-300"
|
||||||
class:blur-3xl={post.post.nsfw && $userSettings.nsfwBlur}
|
class:opacity-100={loaded}
|
||||||
on:load={() => (loaded = true)}
|
width={512}
|
||||||
/>
|
height={300}
|
||||||
</picture>
|
class:blur-3xl={post.post.nsfw && $userSettings.nsfwBlur}
|
||||||
</a>
|
on:load={() => (loaded = true)}
|
||||||
|
/>
|
||||||
|
</picture>
|
||||||
|
</svelte:element>
|
||||||
|
</svelte:component>
|
||||||
{:else if post.post.url}
|
{:else if post.post.url}
|
||||||
<PostLink
|
<PostLink
|
||||||
url={post.post.url}
|
url={post.post.url}
|
||||||
@@ -113,23 +122,29 @@
|
|||||||
</div>
|
</div>
|
||||||
{#if $userSettings.showCompactPosts && (post.post.thumbnail_url || isImage(post.post.url))}
|
{#if $userSettings.showCompactPosts && (post.post.thumbnail_url || isImage(post.post.url))}
|
||||||
<div class="flex-none w-24 h-24">
|
<div class="flex-none w-24 h-24">
|
||||||
<a href="/post/{getInstance()}/{post.post.id}">
|
{#if !$userSettings.expandImages || (post.post.thumbnail_url && !isImage(post.post.url))}
|
||||||
{#if post.post.thumbnail_url}
|
<a href={postLink(post.post)}>
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
{#if post.post.thumbnail_url}
|
||||||
<img
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
src="{post.post.thumbnail_url}?thumbnail=256&format=webp"
|
<img
|
||||||
loading="lazy"
|
src={bestImageURL(post.post, true)}
|
||||||
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
|
loading="lazy"
|
||||||
/>
|
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
|
||||||
{:else}
|
/>
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
{/if}
|
||||||
<img
|
</a>
|
||||||
src="{post.post.url}?thumbnail=256&format=webp"
|
{:else}
|
||||||
loading="lazy"
|
<ExpandableImage url={bestImageURL(post.post, false)}>
|
||||||
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
|
{#if post.post.thumbnail_url}
|
||||||
/>
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
{/if}
|
<img
|
||||||
</a>
|
src={bestImageURL(post.post, true)}
|
||||||
|
loading="lazy"
|
||||||
|
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</ExpandableImage>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,26 @@
|
|||||||
import type { CommentView, PersonView, PostView } from 'lemmy-js-client'
|
import { getInstance } from '$lib/lemmy.js'
|
||||||
|
import type { CommentView, PersonView, Post, PostView } from 'lemmy-js-client'
|
||||||
|
|
||||||
export const isMutable = (post: PostView, me: PersonView) =>
|
export const isMutable = (post: PostView, me: PersonView) =>
|
||||||
(me.person.admin && post.post.local) || me.person.id == post.creator.id
|
(me.person.admin && post.post.local) || me.person.id == post.creator.id
|
||||||
|
|
||||||
export const isCommentMutable = (comment: CommentView, me: PersonView) =>
|
export const isCommentMutable = (comment: CommentView, me: PersonView) =>
|
||||||
me.person.id == comment.creator.id
|
me.person.id == comment.creator.id
|
||||||
|
|
||||||
|
export const bestImageURL = (
|
||||||
|
post: Post,
|
||||||
|
compact: boolean = true,
|
||||||
|
width: number = 1024
|
||||||
|
) => {
|
||||||
|
if (compact && post.thumbnail_url)
|
||||||
|
return `${post.thumbnail_url}?thumbnail=256&format=webp`
|
||||||
|
else if (compact && post.url) return `${post.url}?thumbnail=256&format=webp`
|
||||||
|
|
||||||
|
if (post.url) return `${post.url}?thumbnail=${width}&format=webp`
|
||||||
|
else if (post.thumbnail_url)
|
||||||
|
return `${post.thumbnail_url}?thumbnail=${width}&format=webp`
|
||||||
|
|
||||||
|
return post.url ?? ''
|
||||||
|
}
|
||||||
|
|
||||||
|
export const postLink = (post: Post) => `/post/${getInstance()}/${post.id}`
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Button } from 'mono-svelte'
|
||||||
|
import { Icon, XMark } from 'svelte-hero-icons'
|
||||||
|
import { expoOut } from 'svelte/easing'
|
||||||
|
import { fade, scale } from 'svelte/transition'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full-resolution image URL
|
||||||
|
*/
|
||||||
|
export let url: string
|
||||||
|
export let alt: string = ''
|
||||||
|
export let open: boolean = false
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:body
|
||||||
|
on:keydown={(e) => {
|
||||||
|
if (open && e.code == 'Escape') open = false
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{#if open}
|
||||||
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
|
<!-- svelte-ignore a11y-positive-tabindex -->
|
||||||
|
<div
|
||||||
|
class="fixed top-0 left-0 w-screen h-screen overflow-auto bg-black/50 flex flex-col z-[100]"
|
||||||
|
transition:fade={{ duration: 200 }}
|
||||||
|
on:click={() => (open = false)}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
size="square-md"
|
||||||
|
class="absolute z-[110] top-0 right-0 m-4"
|
||||||
|
on:click={() => (open = false)}
|
||||||
|
>
|
||||||
|
<Icon src={XMark} size="16" mini slot="prefix" />
|
||||||
|
</Button>
|
||||||
|
<img
|
||||||
|
src={url}
|
||||||
|
class="w-full h-full object-contain max-w-screen-sm mx-auto my-auto"
|
||||||
|
transition:scale={{ start: 0.9, easing: expoOut }}
|
||||||
|
{alt}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<button on:click={() => (open = !open)} class="w-max">
|
||||||
|
<slot />
|
||||||
|
</button>
|
||||||
@@ -54,6 +54,7 @@ interface Settings {
|
|||||||
modlogCardView: boolean | undefined
|
modlogCardView: boolean | undefined
|
||||||
debugInfo: boolean
|
debugInfo: boolean
|
||||||
systemUI: boolean
|
systemUI: boolean
|
||||||
|
expandImages: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultSettings: Settings = {
|
export const defaultSettings: Settings = {
|
||||||
@@ -93,6 +94,7 @@ export const defaultSettings: Settings = {
|
|||||||
modlogCardView: toBool(env.PUBLIC_MODLOG_CARD_VIEW) ?? undefined,
|
modlogCardView: toBool(env.PUBLIC_MODLOG_CARD_VIEW) ?? undefined,
|
||||||
debugInfo: false,
|
debugInfo: false,
|
||||||
systemUI: true,
|
systemUI: true,
|
||||||
|
expandImages: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const userSettings = writable(defaultSettings)
|
export const userSettings = writable(defaultSettings)
|
||||||
|
|||||||
@@ -145,6 +145,15 @@
|
|||||||
</Checkbox>
|
</Checkbox>
|
||||||
<span slot="description">Alternate vote design</span>
|
<span slot="description">Alternate vote design</span>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting>
|
||||||
|
<Checkbox bind:checked={$userSettings.expandImages} slot="title">
|
||||||
|
Expand Images
|
||||||
|
</Checkbox>
|
||||||
|
<span slot="description">
|
||||||
|
Clicking on an image brings you to an expanded view rather than sending
|
||||||
|
you to the post page.
|
||||||
|
</span>
|
||||||
|
</Setting>
|
||||||
|
|
||||||
<SectionTitle class="mt-4">Instances</SectionTitle>
|
<SectionTitle class="mt-4">Instances</SectionTitle>
|
||||||
<Setting>
|
<Setting>
|
||||||
|
|||||||
Reference in new issue
Block a user