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 { 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 {
|
||||
/**
|
||||
* The full-resolution image URL
|
||||
@@ -69,76 +55,34 @@
|
||||
width={400}
|
||||
height={400}
|
||||
src={page.state.openImage}
|
||||
class="{zoomed
|
||||
? 'object-cover'
|
||||
: '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}
|
||||
class={[
|
||||
'max-w-max mx-auto my-auto overscroll-contain bg-white dark:bg-zinc-900',
|
||||
]}
|
||||
transition:scale={{ start: 0.95, easing: expoOut, duration: 250 }}
|
||||
{alt}
|
||||
/>
|
||||
<div
|
||||
class="sticky z-10 bottom-4 left-1/2 -translate-x-1/2 w-max"
|
||||
transition:fly={{ duration: 350, y: 14, easing: backOut }}
|
||||
>
|
||||
<div class="sticky z-10 bottom-4 left-1/2 -translate-x-1/2 w-max">
|
||||
<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"
|
||||
padding="none"
|
||||
color="uniform"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button
|
||||
download
|
||||
href={page.state.openImage}
|
||||
color="tertiary"
|
||||
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') })
|
||||
}
|
||||
onclick={() => {
|
||||
navigator.clipboard.writeText(page.state.openImage)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}}
|
||||
color="tertiary"
|
||||
size="square-lg"
|
||||
rounding="pill"
|
||||
title={$t('post.actions.more.share')}
|
||||
loading={sharing}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={Share} size="20" micro />
|
||||
{/snippet}
|
||||
</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
|
||||
onclick={() => history.back()}
|
||||
color="tertiary"
|
||||
|
||||
@@ -71,11 +71,6 @@
|
||||
|
||||
<svelte:element
|
||||
this={element}
|
||||
onclick={bubble('click')}
|
||||
onkeypress={bubble('keypress')}
|
||||
onkeydown={bubble('keydown')}
|
||||
onkeyup={bubble('keyup')}
|
||||
onfocus={bubble('focus')}
|
||||
{...rest}
|
||||
class="{elevationClass[elevation]}
|
||||
{paddingClass[padding]}
|
||||
|
||||
Reference in new issue
Block a user