diff --git a/src/app.d.ts b/src/app.d.ts index 444fc238..b660ebc8 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -17,6 +17,9 @@ declare global { } } } + interface PageState { + openImage: url + } // interface Platform {} } declare const __VERSION__: string diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte index 46e7b80a..f3845ce5 100644 --- a/src/lib/components/lemmy/post/Post.svelte +++ b/src/lib/components/lemmy/post/Post.svelte @@ -21,6 +21,7 @@ import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte' import PostBody from './PostBody.svelte' import { profile } from '$lib/auth' + import { goto } from '$app/navigation' export let post: PostView export let actions: boolean = true @@ -35,7 +36,7 @@ + {#if view == 'cozy' || view == 'list'} + + {/if}
-
+
{/if}
- +
+ +
{#if post.post.body && !post.post.nsfw && view != 'compact'} {/if} diff --git a/src/lib/components/lemmy/post/media/PostMedia.svelte b/src/lib/components/lemmy/post/media/PostMedia.svelte index cce638c1..b8b7ca65 100644 --- a/src/lib/components/lemmy/post/media/PostMedia.svelte +++ b/src/lib/components/lemmy/post/media/PostMedia.svelte @@ -7,7 +7,9 @@ type MediaType, iframeType, } from '$lib/components/lemmy/post/helpers.js' - import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte' + import ExpandableImage, { + showImage, + } from '$lib/components/ui/ExpandableImage.svelte' import { userSettings } from '$lib/settings.js' import { isImage, isVideo } from '$lib/ui/image' import type { Post } from 'lemmy-js-client' @@ -25,40 +27,37 @@ {#if type == 'image'} {#if view == 'card' || view == 'cozy'} - showImage(bestImageURL(post, false, 2048))} + role="button" + tabindex="0" > - - - - - - + + + + - - - + width={512} + height={300} + class:blur-3xl={post.nsfw && $userSettings.nsfwBlur} + /> + + {/if} {:else if (type == 'iframe' || type == 'video') && (view == 'cozy' || view == 'card') && post.url} + import { pushState } from '$app/navigation' + + export function showImage(url: string, alt: string = '') { + pushState('', { + openImage: url, + }) + } + + - { - if (open && e.code == 'Escape') open = false - }} -/> - -{#if open} +{#if $page.state.openImage || '' != ''} @@ -27,19 +30,15 @@ class="!isolate fixed top-0 left-0 w-screen h-screen overflow-auto bg-black/50 flex flex-col z-[200] overscroll-contain" transition:fade={{ duration: 200 }} - on:click={() => (open = false)} + on:click={() => history.back()} > - {/if} - diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 6e135be2..87306b3b 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -18,6 +18,7 @@ import Shell from '$lib/components/ui/layout/Shell.svelte' import SiteCard from '$lib/components/lemmy/SiteCard.svelte' import { site } from '$lib/lemmy.js' + import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte' nProgress.configure({ minimum: 0.4, @@ -83,6 +84,8 @@ > + +