cleanup: remove useless features from expandedimage
This commit is contained in:
1 parent
055ea6b9a5
commit
00f2a80a05
3 files changed
+14
-70
No files matched your search
@@ -24,20 +24,6 @@
|
|||||||
import { focusTrap } from 'svelte-focus-trap'
|
import { focusTrap } from 'svelte-focus-trap'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
|
||||||
let zoomed = $state(false)
|
|
||||||
let sharing = $state(false)
|
|
||||||
|
|
||||||
async function downloadImage(url: string) {
|
|
||||||
sharing = true
|
|
||||||
const response = await fetch(url)
|
|
||||||
|
|
||||||
const blob = await response.blob()
|
|
||||||
|
|
||||||
const file = new File([blob], `photon_image.webp`, { type: blob.type })
|
|
||||||
|
|
||||||
sharing = false
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
interface Props {
|
interface Props {
|
||||||
/**
|
/**
|
||||||
* The full-resolution image URL
|
* The full-resolution image URL
|
||||||
@@ -69,76 +55,34 @@
|
|||||||
width={400}
|
width={400}
|
||||||
height={400}
|
height={400}
|
||||||
src={page.state.openImage}
|
src={page.state.openImage}
|
||||||
class="{zoomed
|
class={[
|
||||||
? 'object-cover'
|
'max-w-max mx-auto my-auto overscroll-contain bg-white dark:bg-zinc-900',
|
||||||
: 'object-contain'} max-w-max mx-auto my-auto overscroll-contain bg-white dark:bg-zinc-900"
|
]}
|
||||||
class:max-w-screen-md={!zoomed}
|
|
||||||
class:w-full={!zoomed}
|
|
||||||
class:min-h-screen={zoomed}
|
|
||||||
class:min-w-screen={zoomed}
|
|
||||||
class:w-max={zoomed}
|
|
||||||
transition:scale={{ start: 0.95, easing: expoOut, duration: 250 }}
|
transition:scale={{ start: 0.95, easing: expoOut, duration: 250 }}
|
||||||
{alt}
|
{alt}
|
||||||
/>
|
/>
|
||||||
<div
|
<div class="sticky z-10 bottom-4 left-1/2 -translate-x-1/2 w-max">
|
||||||
class="sticky z-10 bottom-4 left-1/2 -translate-x-1/2 w-max"
|
|
||||||
transition:fly={{ duration: 350, y: 14, easing: backOut }}
|
|
||||||
>
|
|
||||||
<Material
|
<Material
|
||||||
class="gap-1 p-2 flex flex-row items-center dark:bg-zinc-950"
|
class="gap-1 p-0.5 px-1 flex flex-row items-center dark:bg-zinc-950/50 border-opacity-50"
|
||||||
rounding="full"
|
rounding="full"
|
||||||
padding="none"
|
padding="none"
|
||||||
color="uniform"
|
color="uniform"
|
||||||
onclick={(e) => e.stopPropagation()}
|
onclick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
download
|
onclick={() => {
|
||||||
href={page.state.openImage}
|
navigator.clipboard.writeText(page.state.openImage)
|
||||||
color="tertiary"
|
toast({ content: $t('toast.copied') })
|
||||||
size="square-lg"
|
|
||||||
rounding="pill"
|
|
||||||
title={$t('routes.profile.media.download')}
|
|
||||||
>
|
|
||||||
<Icon src={ArrowDownTray} size="20" micro />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onclick={async () => {
|
|
||||||
if (navigator.share) {
|
|
||||||
const file = await downloadImage(page.state.openImage)
|
|
||||||
|
|
||||||
navigator?.share?.({
|
|
||||||
files: [file],
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
navigator.clipboard.writeText(page.state.openImage)
|
|
||||||
toast({ content: $t('toast.copied') })
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
size="square-lg"
|
size="square-lg"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
title={$t('post.actions.more.share')}
|
title={$t('post.actions.more.share')}
|
||||||
loading={sharing}
|
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={Share} size="20" micro />
|
<Icon src={Share} size="20" micro />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
|
||||||
onclick={() => {
|
|
||||||
zoomed = !zoomed
|
|
||||||
}}
|
|
||||||
color="tertiary"
|
|
||||||
size="square-lg"
|
|
||||||
rounding="pill"
|
|
||||||
title={zoomed ? $t('post.image.zoomOut') : $t('post.image.zoomIn')}
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
src={zoomed ? MagnifyingGlassMinus : MagnifyingGlassPlus}
|
|
||||||
size="20"
|
|
||||||
micro
|
|
||||||
/>
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
onclick={() => history.back()}
|
onclick={() => history.back()}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
|
|||||||
@@ -71,11 +71,6 @@
|
|||||||
|
|
||||||
<svelte:element
|
<svelte:element
|
||||||
this={element}
|
this={element}
|
||||||
onclick={bubble('click')}
|
|
||||||
onkeypress={bubble('keypress')}
|
|
||||||
onkeydown={bubble('keydown')}
|
|
||||||
onkeyup={bubble('keyup')}
|
|
||||||
onfocus={bubble('focus')}
|
|
||||||
{...rest}
|
{...rest}
|
||||||
class="{elevationClass[elevation]}
|
class="{elevationClass[elevation]}
|
||||||
{paddingClass[padding]}
|
{paddingClass[padding]}
|
||||||
|
|||||||
@@ -316,9 +316,14 @@
|
|||||||
open={data.post.cross_posts?.length <= 3}
|
open={data.post.cross_posts?.length <= 3}
|
||||||
>
|
>
|
||||||
{#snippet title()}
|
{#snippet title()}
|
||||||
<div class="inline-block w-full text-left text-base font-normal">
|
<div
|
||||||
|
class="flex items-center gap-1 w-full text-left text-base font-normal"
|
||||||
|
>
|
||||||
<span class="font-bold">{data.post.cross_posts.length}</span>
|
<span class="font-bold">{data.post.cross_posts.length}</span>
|
||||||
{$t('routes.post.crosspostCount')}
|
{$t('routes.post.crosspostCount')}
|
||||||
|
<hr
|
||||||
|
class="flex-1 inline-block w-full border-slate-200 dark:border-zinc-800 mx-3"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in new issue
Block a user