aria: improve semantics

This commit is contained in:
James Xylight committed 2025-08-23 21:58:41 -07:00
1 parent ff1c8f50b2
commit 0c33480a84
19 files changed
+175 -172

No files matched your search

+3 -21
View File
@@ -1,10 +1,10 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { profile } from '$lib/auth.svelte'
import PostActions from '$lib/components/lemmy/post/actions/PostActions.svelte'
import { mediaType, postLink } from '$lib/components/lemmy/post/helpers.js'
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte'
import PostActions from '$lib/components/lemmy/post/actions/PostActions.svelte'
import PostMeta, {
parseTags,
type Tag,
@@ -28,15 +28,6 @@
return rule
}
function onClick(e: Event) {
const event = e as Event
const parent = document.getElementById(post.post.id.toString())
if (event.target == parent) {
goto(postLink(post.post))
}
}
interface Props {
post: PostView
actions?: boolean
@@ -86,9 +77,7 @@
This is the sole component for displaying posts.
It adapts to all kinds of form factors for different contexts, such as feeds, full post view, and crosspost list.
-->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<div
<article
class={[
'post relative max-w-full min-w-0 w-full cursor-pointer outline-hidden group/post',
settings.leftAlign && 'left-align',
@@ -97,13 +86,6 @@
clazz,
]}
id={post.post.id.toString()}
onclick={e => {
onClick(e)
}}
onkeydown={e => {
if (e.key == 'Enter') onClick(e)
}}
tabindex="0"
{style}
>
<PostMeta
@@ -167,7 +149,7 @@
group-hover/post:inset-y-0.5 group-hover/post:-inset-x-3 sm:group-hover/post:-inset-x-5 group-hover/post:opacity-100
duration-150"
></div>
</div>
</article>
<style lang="postcss">
.list-type {
@@ -343,7 +343,6 @@
view == 'compact' ? 'text-base' : 'text-lg',
]}
style="grid-area: title;"
data-sveltekit-preload-data="tap"
>
{#if title}
<Markdown
@@ -29,64 +29,65 @@
For embed-type posts. Displays embed card or a compact link.
-->
{#if embed_title && view == 'cozy'}
<a target="_blank" href={url} class="group/link">
<Material
color="uniform"
class={[
'flex flex-col-reverse sm:flex-row overflow-hidden gap-4 embed-card z-0 relative',
'dark:bg-zinc-950 group-hover/link:bg-slate-50 dark:group-hover/link:bg-zinc-900 transition-colors',
]}
rounding="2xl"
element="article"
padding="sm"
>
{#if thumbnail_url}
<img
src={optimizeImageURL(thumbnail_url, 32)}
alt=""
class="-z-10 absolute w-full object-cover h-full opacity-5 brightness-150
<Material
color="uniform"
class={[
'flex flex-col-reverse sm:flex-row overflow-hidden gap-4 z-0 relative',
'dark:bg-zinc-950 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors',
'group/link',
]}
rounding="2xl"
element="a"
padding="sm"
href={url}
target="_blank"
>
{#if thumbnail_url}
<img
src={optimizeImageURL(thumbnail_url, 32)}
alt=""
class="-z-10 absolute w-full object-cover h-full opacity-5 brightness-150
dark:brightness-70 dark:opacity-10 blur-2xl -inset-px"
/>
/>
{/if}
<div class={['flex flex-col gap-1 p-2', thumbnail_url && '-mt-2 sm:mt-0']}>
{#if richURL}
<div
class="text-slate-600 dark:text-zinc-400 inline-flex items-center gap-1 text-xs font-medium"
>
{richURL.hostname}
</div>
{/if}
<div class="flex flex-col gap-1 p-3 -mt-2 sm:mt-0">
{#if richURL}
<div
class="text-slate-600 dark:text-zinc-400 inline-flex items-center gap-1 text-xs font-medium"
>
{richURL.hostname}
</div>
{/if}
<p class="font-medium text-base">{embed_title}</p>
</div>
{#if thumbnail_url}
<picture class="mb-auto sm:ml-auto shrink-0 sm:w-1/3 sm:max-w-60">
{#each ['webp'] as format}
<source
srcset="{optimizeImageURL(
thumbnail_url,
256,
format as 'avif' | 'webp',
)} 256w, {optimizeImageURL(
thumbnail_url,
512,
format as 'avif' | 'webp',
)} 512w"
media="(min-width: 0px)"
type="image/{format}"
/>
{/each}
<img
src={optimizeImageURL(thumbnail_url, -1)}
class="object-cover w-full sm:max-w-96 h-32 sm:min-h-16 bg-slate-200 dark:bg-zinc-800 rounded-xl"
width={600}
height={400}
alt=""
class:blur-3xl={nsfw}
<p class="font-medium text-base">{embed_title}</p>
</div>
{#if thumbnail_url}
<picture class="mb-auto sm:ml-auto shrink-0 sm:w-1/3 sm:max-w-60">
{#each ['webp'] as format}
<source
srcset="{optimizeImageURL(
thumbnail_url,
256,
format as 'avif' | 'webp',
)} 256w, {optimizeImageURL(
thumbnail_url,
512,
format as 'avif' | 'webp',
)} 512w"
media="(min-width: 0px)"
type="image/{format}"
/>
</picture>
{/if}
</Material>
</a>
{/each}
<img
src={optimizeImageURL(thumbnail_url, -1)}
class="object-cover w-full sm:max-w-96 h-32 sm:min-h-16 bg-slate-200 dark:bg-zinc-800 rounded-xl"
width={600}
height={400}
alt=""
class:blur-3xl={nsfw}
/>
</picture>
{/if}
</Material>
{:else}
<a
href={url}