misc: improve alt text handling
This commit is contained in:
1 parent
3874160ce5
commit
ed0236a5f6
4 files changed
+214
-199
No files matched your search
@@ -13,11 +13,14 @@
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { Post } from 'lemmy-js-client'
|
||||
import PostIframe from './PostIframe.svelte'
|
||||
import { Button, Material } from 'mono-svelte'
|
||||
|
||||
export let view: 'card' | 'cozy' | 'list' | 'compact' = 'cozy'
|
||||
export let post: Post
|
||||
export let type: MediaType = 'none'
|
||||
export let opened: boolean | undefined = undefined
|
||||
|
||||
let showAltText = false
|
||||
</script>
|
||||
|
||||
{#if type == 'image'}
|
||||
@@ -70,12 +73,22 @@
|
||||
/>
|
||||
</picture>
|
||||
{#if post.alt_text}
|
||||
<button
|
||||
class="absolute bottom-0 left-0 text-sm m-2 bg-white dark:bg-zinc-900 px-3 py-1.5
|
||||
rounded-full border border-slate-200 dark:border-zinc-800 shadow-lg text-left"
|
||||
<Button
|
||||
on:click={(e) => {
|
||||
e.stopPropagation()
|
||||
showAltText = !showAltText
|
||||
}}
|
||||
class="absolute bottom-0 left-0 text-sm m-2 text-left"
|
||||
size="sm"
|
||||
rounding="pill"
|
||||
alignment="left"
|
||||
>
|
||||
{post.alt_text}
|
||||
</button>
|
||||
{#if showAltText}
|
||||
{post.alt_text}
|
||||
{:else}
|
||||
<span class="font-bold">ALT</span>
|
||||
{/if}
|
||||
</Button>
|
||||
{/if}
|
||||
</svelte:element>
|
||||
{/if}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { isImage } from '$lib/ui/image'
|
||||
import type { Post } from 'lemmy-js-client'
|
||||
import { Material, Popover } from 'mono-svelte'
|
||||
import { DocumentText, Icon, Link, VideoCamera } from 'svelte-hero-icons'
|
||||
|
||||
export let view: 'card' | 'cozy' | 'list' | 'compact' = 'cozy'
|
||||
@@ -18,9 +19,25 @@
|
||||
|
||||
{#if view == 'compact' || (view == 'list' && (!post.embed_title || type == 'iframe') && type != 'none')}
|
||||
<div
|
||||
class="w-24 sm:w-32 h-24 group/media {$$props.class ?? ''}"
|
||||
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
|
||||
style={$$props.style ?? ''}
|
||||
>
|
||||
{#if post.alt_text}
|
||||
<Popover openOnHover placement="bottom-end">
|
||||
<Material
|
||||
slot="target"
|
||||
padding="none"
|
||||
rounding="full"
|
||||
elevation="high"
|
||||
class="w-max absolute bottom-0 left-0 py-0.5 px-1.5 m-1 font-bold"
|
||||
>
|
||||
ALT
|
||||
</Material>
|
||||
<div class="max-w-sm">
|
||||
{post.alt_text}
|
||||
</div>
|
||||
</Popover>
|
||||
{/if}
|
||||
<svelte:element
|
||||
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
|
||||
href={postLink(post)}
|
||||
|
||||
Reference in new issue
Block a user