impr: make post semantics better
This commit is contained in:
1 parent
6831a640c5
commit
aea47580bf
13 files changed
+178
-163
No files matched your search
@@ -83,6 +83,7 @@
|
|||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<Material
|
<Material
|
||||||
|
element="article"
|
||||||
color={view != 'card' ? 'none' : 'distinct'}
|
color={view != 'card' ? 'none' : 'distinct'}
|
||||||
class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none group
|
class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none group
|
||||||
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
|
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
|
||||||
@@ -160,7 +161,12 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/key}
|
{/key}
|
||||||
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody && rule != 'hide'}
|
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody && rule != 'hide'}
|
||||||
<PostBody body={post.post.body} {view} style="grid-area: body" />
|
<PostBody
|
||||||
|
element="section"
|
||||||
|
body={post.post.body}
|
||||||
|
{view}
|
||||||
|
style="grid-area: body"
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if actions}
|
{#if actions}
|
||||||
<PostActions on:hide bind:post style="grid-area: actions;" {view} />
|
<PostActions on:hide bind:post style="grid-area: actions;" {view} />
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div
|
<footer
|
||||||
class="flex flex-row gap-2 items-center flex-shrink-0 {buttonHeight}"
|
class="flex flex-row gap-2 items-center flex-shrink-0 {buttonHeight}"
|
||||||
style={$$props.style ?? ''}
|
style={$$props.style ?? ''}
|
||||||
>
|
>
|
||||||
@@ -398,4 +398,4 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</footer>
|
||||||
@@ -7,6 +7,10 @@
|
|||||||
export let body: string
|
export let body: string
|
||||||
export let view: View = 'cozy'
|
export let view: View = 'cozy'
|
||||||
export let clickThrough = false
|
export let clickThrough = false
|
||||||
|
let htmlElement = 'div'
|
||||||
|
|
||||||
|
export { htmlElement as element }
|
||||||
|
|
||||||
let expanded = false
|
let expanded = false
|
||||||
let element: Element
|
let element: Element
|
||||||
|
|
||||||
@@ -25,7 +29,8 @@
|
|||||||
$: overflows = isOverflown(element, body)
|
$: overflows = isOverflown(element, body)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<svelte:element
|
||||||
|
this={htmlElement}
|
||||||
style={$$props.style ?? ''}
|
style={$$props.style ?? ''}
|
||||||
class="{!expanded
|
class="{!expanded
|
||||||
? `text-sm overflow-hidden
|
? `text-sm overflow-hidden
|
||||||
@@ -55,4 +60,4 @@ ${view == 'list' ? `max-h-24` : 'max-h-48'}`
|
|||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</svelte:element>
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
@component
|
@component
|
||||||
This component will build two different things: a post's meta block and the title.
|
This component will build two different things: a post's meta block and the title.
|
||||||
-->
|
-->
|
||||||
<div
|
<header
|
||||||
class="grid w-full meta {community
|
class="grid w-full meta {community
|
||||||
? 'grid-rows-2'
|
? 'grid-rows-2'
|
||||||
: 'grid-rows-1'} text-xs min-w-0 max-w-full"
|
: 'grid-rows-1'} text-xs min-w-0 max-w-full"
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
url={community.icon}
|
url={community.icon}
|
||||||
width={28}
|
width={32}
|
||||||
alt={community.name}
|
alt={community.name}
|
||||||
style="grid-area: avatar; height: 100%;"
|
style="grid-area: avatar; height: 100%;"
|
||||||
class="flex-shrink-0"
|
class="flex-shrink-0"
|
||||||
@@ -159,16 +159,18 @@
|
|||||||
style="grid-area: stats;"
|
style="grid-area: stats;"
|
||||||
>
|
>
|
||||||
{#if user}
|
{#if user}
|
||||||
<UserLink avatarSize={20} {user} avatar={!showCommunity}>
|
<address>
|
||||||
<svelte:fragment slot="badges">
|
<UserLink avatarSize={20} {user} avatar={!showCommunity}>
|
||||||
{#if badges.moderator}
|
<svelte:fragment slot="badges">
|
||||||
<ShieldIcon filled width={14} class="text-green-500" />
|
{#if badges.moderator}
|
||||||
{/if}
|
<ShieldIcon filled width={14} class="text-green-500" />
|
||||||
{#if badges.admin}
|
{/if}
|
||||||
<ShieldIcon filled width={14} class="text-red-500" />
|
{#if badges.admin}
|
||||||
{/if}
|
<ShieldIcon filled width={14} class="text-red-500" />
|
||||||
</svelte:fragment>
|
{/if}
|
||||||
</UserLink>
|
</svelte:fragment>
|
||||||
|
</UserLink>
|
||||||
|
</address>
|
||||||
{/if}
|
{/if}
|
||||||
{#if published}
|
{#if published}
|
||||||
<RelativeDate date={published} class="flex-shrink-0" />
|
<RelativeDate date={published} class="flex-shrink-0" />
|
||||||
@@ -251,7 +253,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<slot name="badges" />
|
<slot name="badges" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</header>
|
||||||
{#if title && id}
|
{#if title && id}
|
||||||
<a
|
<a
|
||||||
href="/post/{getInstance()}/{id}"
|
href="/post/{getInstance()}/{id}"
|
||||||
|
|||||||
@@ -64,6 +64,8 @@
|
|||||||
? ''
|
? ''
|
||||||
: '!text-inherit'} !text-inherit divide-x divide-slate-200 dark:divide-zinc-800
|
: '!text-inherit'} !text-inherit divide-x divide-slate-200 dark:divide-zinc-800
|
||||||
{loading ? 'animate-pulse opacity-75 pointer-events-none' : ''}"
|
{loading ? 'animate-pulse opacity-75 pointer-events-none' : ''}"
|
||||||
|
role="group"
|
||||||
|
aria-label={$t('aria.vote.group')}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
on:click={() => castVote(vote == 1 ? 0 : 1)}
|
on:click={() => castVote(vote == 1 ? 0 : 1)}
|
||||||
@@ -71,6 +73,8 @@
|
|||||||
{vote == 1
|
{vote == 1
|
||||||
? shouldShowVoteColor(vote, 'upvotes')
|
? shouldShowVoteColor(vote, 'upvotes')
|
||||||
: 'hover:bg-slate-100 hover:dark:bg-zinc-800'}"
|
: 'hover:bg-slate-100 hover:dark:bg-zinc-800'}"
|
||||||
|
aria-pressed={vote == 1}
|
||||||
|
aria-label={$t('post.actions.vote.upvote')}
|
||||||
>
|
>
|
||||||
<Icon src={ChevronUp} size="20" micro />
|
<Icon src={ChevronUp} size="20" micro />
|
||||||
<span class="grid text-sm">
|
<span class="grid text-sm">
|
||||||
@@ -79,6 +83,7 @@
|
|||||||
style="grid-column: 1; grid-row: 1;"
|
style="grid-column: 1; grid-row: 1;"
|
||||||
in:fly={{ duration: 400, y: -10, easing: backOut }}
|
in:fly={{ duration: 400, y: -10, easing: backOut }}
|
||||||
out:fly={{ duration: 400, y: 10, easing: backOut }}
|
out:fly={{ duration: 400, y: 10, easing: backOut }}
|
||||||
|
aria-label={$t('aria.vote.upvotes', { default: upvotes })}
|
||||||
>
|
>
|
||||||
<FormattedNumber number={upvotes} />
|
<FormattedNumber number={upvotes} />
|
||||||
</span>
|
</span>
|
||||||
@@ -92,6 +97,8 @@
|
|||||||
{vote == -1
|
{vote == -1
|
||||||
? shouldShowVoteColor(vote, 'downvotes')
|
? shouldShowVoteColor(vote, 'downvotes')
|
||||||
: 'hover:bg-slate-100 hover:dark:bg-zinc-800'}"
|
: 'hover:bg-slate-100 hover:dark:bg-zinc-800'}"
|
||||||
|
aria-pressed={vote == -1}
|
||||||
|
aria-label={$t('post.actions.vote.downvote')}
|
||||||
>
|
>
|
||||||
<Icon src={ChevronDown} size="20" micro />
|
<Icon src={ChevronDown} size="20" micro />
|
||||||
<span class="grid text-sm">
|
<span class="grid text-sm">
|
||||||
@@ -100,6 +107,7 @@
|
|||||||
style="grid-column: 1; grid-row: 1;"
|
style="grid-column: 1; grid-row: 1;"
|
||||||
in:fly={{ duration: 400, y: -10, easing: backOut }}
|
in:fly={{ duration: 400, y: -10, easing: backOut }}
|
||||||
out:fly={{ duration: 400, y: 10, easing: backOut }}
|
out:fly={{ duration: 400, y: 10, easing: backOut }}
|
||||||
|
aria-label={$t('aria.vote.downvotes', { default: downvotes })}
|
||||||
>
|
>
|
||||||
<FormattedNumber number={downvotes} />
|
<FormattedNumber number={downvotes} />
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -12,19 +12,8 @@ export const bestImageURL = (
|
|||||||
compact: boolean = true,
|
compact: boolean = true,
|
||||||
width: number = 1024
|
width: number = 1024
|
||||||
) => {
|
) => {
|
||||||
let fetchWidth =
|
if (post.thumbnail_url) return optimizeImageURL(post.thumbnail_url, width)
|
||||||
width > 1024
|
else if (post.url) return optimizeImageURL(post.url, width)
|
||||||
? // -1 disables a small thumbnail
|
|
||||||
-1
|
|
||||||
: // set width to 512 if compact
|
|
||||||
compact
|
|
||||||
? 512
|
|
||||||
: // otherwise, just use the original width
|
|
||||||
width
|
|
||||||
|
|
||||||
if (post.thumbnail_url)
|
|
||||||
return optimizeImageURL(post.thumbnail_url, fetchWidth)
|
|
||||||
else if (post.url) return optimizeImageURL(post.url, fetchWidth)
|
|
||||||
|
|
||||||
return post.url ?? ''
|
return post.url ?? ''
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,12 @@
|
|||||||
-->
|
-->
|
||||||
{#if embed_title && view != 'compact'}
|
{#if embed_title && view != 'compact'}
|
||||||
<Material
|
<Material
|
||||||
style="--img-url: {thumbnail_url}"
|
|
||||||
color="distinct"
|
color="distinct"
|
||||||
class="flex flex-col-reverse sm:flex-row
|
class="flex flex-col-reverse sm:flex-row
|
||||||
overflow-hidden gap-4 embed-card z-0 relative
|
overflow-hidden gap-4 embed-card z-0 relative
|
||||||
dark:border-t-zinc-800 border-opacity-80"
|
dark:border-t-zinc-800 border-opacity-80"
|
||||||
rounding="xl"
|
rounding="xl"
|
||||||
|
element="article"
|
||||||
>
|
>
|
||||||
{#if thumbnail_url}
|
{#if thumbnail_url}
|
||||||
<img
|
<img
|
||||||
@@ -187,16 +187,4 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{#if thumbnail_url && view != 'compact'}
|
|
||||||
<a href={url} target="_blank">
|
|
||||||
<img
|
|
||||||
src={optimizeImageURL(thumbnail_url, 256)}
|
|
||||||
class="rounded-md max-w-72 w-full h-auto aspect-video object-cover bg-slate-200 dark:bg-zinc-800"
|
|
||||||
width={600}
|
|
||||||
height={400}
|
|
||||||
alt={embed_title ?? 'Embed prevented alt text'}
|
|
||||||
class:blur-3xl={nsfw}
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { userSettings, type View } from '$lib/settings'
|
||||||
|
import type { Post } from 'lemmy-js-client'
|
||||||
|
import { bestImageURL, postLink } from '../helpers'
|
||||||
|
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
||||||
|
import { Button, modal } from 'mono-svelte'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
|
export let post: Post
|
||||||
|
export let blur: boolean = false
|
||||||
|
|
||||||
|
let imageLoaded: boolean | null = null
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
imageLoaded = false
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!--disabled preloads here since most people will hover over every image while scrolling-->
|
||||||
|
<svelte:element
|
||||||
|
this={$userSettings.expandImages ? 'button' : 'a'}
|
||||||
|
href={postLink(post)}
|
||||||
|
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
|
||||||
|
data-sveltekit-preload-data="off"
|
||||||
|
aria-label={post.name}
|
||||||
|
on:click={() => showImage(bestImageURL(post, false, 2048))}
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
|
<img
|
||||||
|
loading="lazy"
|
||||||
|
fetchpriority="auto"
|
||||||
|
src={bestImageURL(post, false, 64)}
|
||||||
|
class="-z-10 absolute top-0 left-0 w-full h-full object-cover blur-lg
|
||||||
|
scale-[1.2] opacity-50"
|
||||||
|
/>
|
||||||
|
<picture class="max-h-[inherit]">
|
||||||
|
<source
|
||||||
|
srcset={bestImageURL(post, false, 256)}
|
||||||
|
media="(max-width: 256px)"
|
||||||
|
/>
|
||||||
|
<source
|
||||||
|
srcset={bestImageURL(post, false, 512)}
|
||||||
|
media="(max-width: 512px)"
|
||||||
|
/>
|
||||||
|
<source
|
||||||
|
srcset={bestImageURL(post, false, 1024)}
|
||||||
|
media="(max-width: 1024px)"
|
||||||
|
/>
|
||||||
|
<source
|
||||||
|
srcset={bestImageURL(post, false, 1512)}
|
||||||
|
media="(max-width: 1512px)"
|
||||||
|
/>
|
||||||
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
|
<img
|
||||||
|
src={bestImageURL(post, false, -1)}
|
||||||
|
loading="lazy"
|
||||||
|
class="max-h-[inherit] max-w-full h-auto z-30
|
||||||
|
transition-opacity duration-500 object-contain mx-auto
|
||||||
|
{imageLoaded === false ? 'opacity-0' : 'opacity-100'}"
|
||||||
|
width={512}
|
||||||
|
height={300}
|
||||||
|
class:blur-3xl={blur}
|
||||||
|
alt={post.alt_text ?? ''}
|
||||||
|
on:load={() => (imageLoaded = true)}
|
||||||
|
/>
|
||||||
|
</picture>
|
||||||
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
|
<div
|
||||||
|
class="absolute bottom-0 left-0 right-0 flex justify-between items-center
|
||||||
|
rounded-full ml-auto w-max m-2 p-0 gap-1
|
||||||
|
*:bg-white *:border *:border-slate-200 *:dark:border-zinc-800 *:dark:bg-zinc-900"
|
||||||
|
on:click|stopPropagation={() => {}}
|
||||||
|
>
|
||||||
|
{#if post.alt_text}
|
||||||
|
<Button
|
||||||
|
on:click={(e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
modal({
|
||||||
|
title: 'Alt',
|
||||||
|
body: post.alt_text ?? '',
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
color="tertiary"
|
||||||
|
size="md"
|
||||||
|
rounding="pill"
|
||||||
|
>
|
||||||
|
ALT
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</svelte:element>
|
||||||
@@ -16,20 +16,13 @@
|
|||||||
import { Button, Material, modal } from 'mono-svelte'
|
import { Button, Material, modal } from 'mono-svelte'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { ArrowDownTray, Icon } from 'svelte-hero-icons'
|
import { ArrowDownTray, Icon } from 'svelte-hero-icons'
|
||||||
|
import PostImage from './PostImage.svelte'
|
||||||
|
|
||||||
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'
|
export let type: MediaType = 'none'
|
||||||
export let opened: boolean | undefined = undefined
|
export let opened: boolean | undefined = undefined
|
||||||
export let blur: boolean = post.nsfw && $userSettings.nsfwBlur
|
export let blur: boolean = post.nsfw && $userSettings.nsfwBlur
|
||||||
|
|
||||||
let showAltText = false
|
|
||||||
|
|
||||||
let imageLoaded: boolean | null = null
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
imageLoaded = false
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -39,94 +32,7 @@
|
|||||||
- Embed link/card.
|
- Embed link/card.
|
||||||
-->
|
-->
|
||||||
{#if type == 'image'}
|
{#if type == 'image'}
|
||||||
{#if view == 'card' || view == 'cozy'}
|
<PostImage {post} {blur} />
|
||||||
<!--disabled preloads here since most people will hover over every image while scrolling-->
|
|
||||||
<svelte:element
|
|
||||||
this={$userSettings.expandImages ? 'button' : 'a'}
|
|
||||||
href={postLink(post)}
|
|
||||||
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
|
|
||||||
data-sveltekit-preload-data="off"
|
|
||||||
aria-label={post.name}
|
|
||||||
on:click={() => showImage(bestImageURL(post, false, 2048))}
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
|
||||||
<img
|
|
||||||
loading="lazy"
|
|
||||||
fetchpriority="auto"
|
|
||||||
src={bestImageURL(post, false, 64)}
|
|
||||||
class="-z-10 absolute top-0 left-0 w-full h-full object-cover blur-lg
|
|
||||||
scale-[1.2] opacity-50"
|
|
||||||
/>
|
|
||||||
<picture class="max-h-[inherit]">
|
|
||||||
<source
|
|
||||||
srcset={bestImageURL(post, false, 256)}
|
|
||||||
media="(max-width: 256px)"
|
|
||||||
/>
|
|
||||||
<source
|
|
||||||
srcset={bestImageURL(post, false, 512)}
|
|
||||||
media="(max-width: 512px)"
|
|
||||||
/>
|
|
||||||
<source
|
|
||||||
srcset={bestImageURL(post, false, 1024)}
|
|
||||||
media="(max-width: 1024px)"
|
|
||||||
/>
|
|
||||||
<source
|
|
||||||
srcset={bestImageURL(post, false, 1512)}
|
|
||||||
media="(max-width: 1512px)"
|
|
||||||
/>
|
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
|
||||||
<img
|
|
||||||
src={bestImageURL(post, false, 2048)}
|
|
||||||
loading="lazy"
|
|
||||||
class="max-h-[inherit] max-w-full h-auto z-30
|
|
||||||
transition-opacity duration-500 object-contain mx-auto
|
|
||||||
{imageLoaded === false ? 'opacity-0' : 'opacity-100'}"
|
|
||||||
width={512}
|
|
||||||
height={300}
|
|
||||||
class:blur-3xl={blur}
|
|
||||||
alt={post.alt_text ?? ''}
|
|
||||||
on:load={() => (imageLoaded = true)}
|
|
||||||
/>
|
|
||||||
</picture>
|
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
||||||
<div
|
|
||||||
class="absolute bottom-0 left-0 right-0 flex justify-between items-center
|
|
||||||
rounded-full ml-auto w-max m-2 p-0 gap-1
|
|
||||||
*:bg-white *:border *:border-slate-200 *:dark:border-zinc-800 *:dark:bg-zinc-900"
|
|
||||||
on:click|stopPropagation={() => {}}
|
|
||||||
>
|
|
||||||
<!-- <Button
|
|
||||||
color="tertiary"
|
|
||||||
size="sm"
|
|
||||||
class="aspect-square"
|
|
||||||
rounding="pill"
|
|
||||||
href={post.url}
|
|
||||||
download
|
|
||||||
>
|
|
||||||
<Icon src={ArrowDownTray} size="16" micro />
|
|
||||||
</Button> -->
|
|
||||||
{#if post.alt_text}
|
|
||||||
<Button
|
|
||||||
on:click={(e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
modal({
|
|
||||||
title: 'Alt',
|
|
||||||
body: post.alt_text ?? '',
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
color="tertiary"
|
|
||||||
size="md"
|
|
||||||
rounding="pill"
|
|
||||||
>
|
|
||||||
ALT
|
|
||||||
</Button>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</svelte:element>
|
|
||||||
{/if}
|
|
||||||
{:else if (type == 'iframe' || type == 'video') && (view == 'cozy' || view == 'card') && post.url}
|
{:else if (type == 'iframe' || type == 'video') && (view == 'cozy' || view == 'card') && post.url}
|
||||||
<PostIframe
|
<PostIframe
|
||||||
thumbnail={post.thumbnail_url}
|
thumbnail={post.thumbnail_url}
|
||||||
|
|||||||
@@ -13,16 +13,21 @@
|
|||||||
export let width: number
|
export let width: number
|
||||||
export let res: number | undefined = undefined
|
export let res: number | undefined = undefined
|
||||||
|
|
||||||
const optimizeUrl = (url: string | undefined): string | undefined => {
|
const optimizeUrl = (
|
||||||
|
url: string | undefined,
|
||||||
|
res: number
|
||||||
|
): string | undefined => {
|
||||||
if (url === undefined) return
|
if (url === undefined) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const urlObj = new URL(url)
|
const urlObj = new URL(url)
|
||||||
urlObj.searchParams.append('format', 'webp')
|
urlObj.searchParams.append('format', 'webp')
|
||||||
urlObj.searchParams.append(
|
if (res > -1) {
|
||||||
'thumbnail',
|
urlObj.searchParams.append(
|
||||||
findClosestNumber(sizes, (res || width) * 1.5).toString()
|
'thumbnail',
|
||||||
)
|
findClosestNumber(sizes, res).toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return urlObj.toString()
|
return urlObj.toString()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -30,13 +35,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: optimizedURL = optimizeUrl(url)
|
$: optimizedURLs = [2, 3, 6, -1].map((n) =>
|
||||||
|
optimizeUrl(url, (res || width) * n)
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if optimizedURL}
|
{#if optimizedURLs}
|
||||||
<img
|
<img
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
src={optimizedURL}
|
srcset="{optimizedURLs[0]} 1x, {optimizedURLs[1]} 2x, {optimizedURLs[2]} 4x, {optimizedURLs[3]} 6x"
|
||||||
|
src={optimizedURLs[0]}
|
||||||
{alt}
|
{alt}
|
||||||
{width}
|
{width}
|
||||||
{title}
|
{title}
|
||||||
|
|||||||
@@ -472,6 +472,10 @@
|
|||||||
"link": {
|
"link": {
|
||||||
"title": "Alternative Links",
|
"title": "Alternative Links",
|
||||||
"actions": "Link Actions"
|
"actions": "Link Actions"
|
||||||
|
},
|
||||||
|
"vote": {
|
||||||
|
"upvote": "Upvote",
|
||||||
|
"downvote": "Downvote"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"badges": {
|
"badges": {
|
||||||
@@ -839,6 +843,11 @@
|
|||||||
"pagination": {
|
"pagination": {
|
||||||
"nav": "Pagination",
|
"nav": "Pagination",
|
||||||
"current": "Current page"
|
"current": "Current page"
|
||||||
|
},
|
||||||
|
"vote": {
|
||||||
|
"group": "Post voting controls",
|
||||||
|
"upvotes": "{{default}} upvotes",
|
||||||
|
"downvotes": "{{default}} downvotes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,23 +127,23 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex flex-col h-full gap-4">
|
<div class="flex flex-col h-full gap-4">
|
||||||
<div class="flex flex-row justify-between">
|
<Header pageHeader>
|
||||||
<Header pageHeader>{$t('routes.accounts')}</Header>
|
{$t('routes.accounts')}
|
||||||
</div>
|
<div class="flex" slot="extended">
|
||||||
<div class="flex">
|
<div class="flex gap-2 mr-auto">
|
||||||
<div class="flex gap-2 mr-auto">
|
<Button href="/login" size="lg" class="flex-1 px-8" color="primary">
|
||||||
<Button href="/login" size="lg" class="flex-1 px-8" color="primary">
|
<Icon slot="prefix" src={ArrowLeftOnRectangle} size="16" mini />
|
||||||
<Icon slot="prefix" src={ArrowLeftOnRectangle} size="16" mini />
|
{$t('account.login')}
|
||||||
{$t('account.login')}
|
|
||||||
</Button>
|
|
||||||
{#if !LINKED_INSTANCE_URL}
|
|
||||||
<Button href="/login/guest" size="lg">
|
|
||||||
<Icon slot="prefix" src={Plus} size="16" mini />
|
|
||||||
{$t('account.addGuest')}
|
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{#if !LINKED_INSTANCE_URL}
|
||||||
|
<Button href="/login/guest" size="lg">
|
||||||
|
<Icon slot="prefix" src={Plus} size="16" mini />
|
||||||
|
{$t('account.addGuest')}
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Header>
|
||||||
<FilterTabs items={$profileData.profiles} id={(i) => i.instance} let:items>
|
<FilterTabs items={$profileData.profiles} id={(i) => i.instance} let:items>
|
||||||
<EditableList
|
<EditableList
|
||||||
on:action={(acc) => {
|
on:action={(acc) => {
|
||||||
|
|||||||
Reference in new issue
Block a user