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

+1
View File
@@ -28,6 +28,7 @@ export default ts.config(
'svelte/require-each-key': 'off', 'svelte/require-each-key': 'off',
'svelte/prefer-writable-derived': 'off', 'svelte/prefer-writable-derived': 'off',
'no-console': 'off', 'no-console': 'off',
'@typescript-eslint/no-explicit-any': 'off',
}, },
}, },
{ {
+1 -3
View File
@@ -13,9 +13,7 @@
> >
<svg width="50" height="50"><use width="50" height="50" xlink:href='/img/logo-isolated.svg' href="/img/logo-isolated.svg"></use></svg> <svg width="50" height="50"><use width="50" height="50" xlink:href='/img/logo-isolated.svg' href="/img/logo-isolated.svg"></use></svg>
</div> </div>
<div <div style="display: contents;">
style="display: contents;"
>
%sveltekit.body% %sveltekit.body%
</div> </div>
</body> </body>
+1 -1
View File
@@ -237,7 +237,7 @@ class Profile {
const id = Math.max(...this.meta.profiles.map(p => p.id)) + 1 const id = Math.max(...this.meta.profiles.map(p => p.id)) + 1
this.meta.profile = id this.meta.profile = id
this.meta.profiles.push({ this.meta.profiles.unshift({
id: id, id: id,
instance: instance, instance: instance,
jwt: jwt, jwt: jwt,
+5 -4
View File
@@ -12,13 +12,14 @@
import LabelStat from '../ui/LabelStat.svelte' import LabelStat from '../ui/LabelStat.svelte'
import ItemList from './generic/ItemList.svelte' import ItemList from './generic/ItemList.svelte'
import { optimizeImageURL } from './post/helpers' import { optimizeImageURL } from './post/helpers'
import type { ClassValue } from 'svelte/elements'
interface Props { interface Props extends HTMLDivElement {
site: SiteView site: SiteView
taglines?: Tagline[] | undefined taglines?: Tagline[] | undefined
admins?: PersonView[] | undefined admins?: PersonView[] | undefined
version?: string | undefined version?: string | undefined
class?: string class?: ClassValue
} }
let { let {
@@ -30,7 +31,7 @@
}: Props = $props() }: Props = $props()
</script> </script>
<div <aside
class={[ class={[
'w-full text-slate-600 dark:text-zinc-400 flex flex-col gap-4 text-sm', 'w-full text-slate-600 dark:text-zinc-400 flex flex-col gap-4 text-sm',
clazz, clazz,
@@ -140,4 +141,4 @@
</Link> </Link>
</div> </div>
</div> </div>
</div> </aside>
@@ -146,11 +146,15 @@
</script> </script>
{#await community_view} {#await community_view}
<div class="w-full h-full grid place-items-center"> <div
class="w-full h-full grid place-items-center"
role="status"
aria-label={$t('aria.loading')}
>
<Spinner width={24} /> <Spinner width={24} />
</div> </div>
{:then community_view} {:then community_view}
<div <aside
class={[ class={[
'min-w-full pt-0 text-slate-600 dark:text-zinc-400 flex flex-col gap-4 text-sm', 'min-w-full pt-0 text-slate-600 dark:text-zinc-400 flex flex-col gap-4 text-sm',
clazz, clazz,
@@ -337,5 +341,5 @@
{/if} {/if}
</Menu> </Menu>
</div> </div>
</div> </aside>
{/await} {/await}
+3 -21
View File
@@ -1,10 +1,10 @@
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { profile } from '$lib/auth.svelte' 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 { mediaType, postLink } from '$lib/components/lemmy/post/helpers.js'
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte' import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte' import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte'
import PostActions from '$lib/components/lemmy/post/actions/PostActions.svelte'
import PostMeta, { import PostMeta, {
parseTags, parseTags,
type Tag, type Tag,
@@ -28,15 +28,6 @@
return rule 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 { interface Props {
post: PostView post: PostView
actions?: boolean actions?: boolean
@@ -86,9 +77,7 @@
This is the sole component for displaying posts. 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. 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 --> <article
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<div
class={[ class={[
'post relative max-w-full min-w-0 w-full cursor-pointer outline-hidden group/post', 'post relative max-w-full min-w-0 w-full cursor-pointer outline-hidden group/post',
settings.leftAlign && 'left-align', settings.leftAlign && 'left-align',
@@ -97,13 +86,6 @@
clazz, clazz,
]} ]}
id={post.post.id.toString()} id={post.post.id.toString()}
onclick={e => {
onClick(e)
}}
onkeydown={e => {
if (e.key == 'Enter') onClick(e)
}}
tabindex="0"
{style} {style}
> >
<PostMeta <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 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" duration-150"
></div> ></div>
</div> </article>
<style lang="postcss"> <style lang="postcss">
.list-type { .list-type {
@@ -343,7 +343,6 @@
view == 'compact' ? 'text-base' : 'text-lg', view == 'compact' ? 'text-base' : 'text-lg',
]} ]}
style="grid-area: title;" style="grid-area: title;"
data-sveltekit-preload-data="tap"
> >
{#if title} {#if title}
<Markdown <Markdown
@@ -29,64 +29,65 @@
For embed-type posts. Displays embed card or a compact link. For embed-type posts. Displays embed card or a compact link.
--> -->
{#if embed_title && view == 'cozy'} {#if embed_title && view == 'cozy'}
<a target="_blank" href={url} class="group/link"> <Material
<Material color="uniform"
color="uniform" class={[
class={[ 'flex flex-col-reverse sm:flex-row overflow-hidden gap-4 z-0 relative',
'flex flex-col-reverse sm:flex-row overflow-hidden gap-4 embed-card z-0 relative', 'dark:bg-zinc-950 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors',
'dark:bg-zinc-950 group-hover/link:bg-slate-50 dark:group-hover/link:bg-zinc-900 transition-colors', 'group/link',
]} ]}
rounding="2xl" rounding="2xl"
element="article" element="a"
padding="sm" padding="sm"
> href={url}
{#if thumbnail_url} target="_blank"
<img >
src={optimizeImageURL(thumbnail_url, 32)} {#if thumbnail_url}
alt="" <img
class="-z-10 absolute w-full object-cover h-full opacity-5 brightness-150 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" 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} {/if}
<div class="flex flex-col gap-1 p-3 -mt-2 sm:mt-0"> <p class="font-medium text-base">{embed_title}</p>
{#if richURL} </div>
<div {#if thumbnail_url}
class="text-slate-600 dark:text-zinc-400 inline-flex items-center gap-1 text-xs font-medium" <picture class="mb-auto sm:ml-auto shrink-0 sm:w-1/3 sm:max-w-60">
> {#each ['webp'] as format}
{richURL.hostname} <source
</div> srcset="{optimizeImageURL(
{/if} thumbnail_url,
<p class="font-medium text-base">{embed_title}</p> 256,
</div> format as 'avif' | 'webp',
{#if thumbnail_url} )} 256w, {optimizeImageURL(
<picture class="mb-auto sm:ml-auto shrink-0 sm:w-1/3 sm:max-w-60"> thumbnail_url,
{#each ['webp'] as format} 512,
<source format as 'avif' | 'webp',
srcset="{optimizeImageURL( )} 512w"
thumbnail_url, media="(min-width: 0px)"
256, type="image/{format}"
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}
/> />
</picture> {/each}
{/if} <img
</Material> src={optimizeImageURL(thumbnail_url, -1)}
</a> 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} {:else}
<a <a
href={url} href={url}
+5 -5
View File
@@ -40,14 +40,14 @@
clazz, clazz,
]} ]}
> >
<span class="font-medium text-left"> <h3 class="font-medium text-left">
{@render children?.()} {@render children?.()}
</span> </h3>
<hr <div
class={[ class={[
'flex-1 border-slate-200 dark:border-zinc-800', 'flex-1 border-slate-200 dark:border-zinc-800 border-b',
!border && 'opacity-0', !border && 'opacity-0',
]} ]}
/> ></div>
{@render action?.()} {@render action?.()}
</div> </div>
-2
View File
@@ -63,7 +63,6 @@
class="text-inherit dark:text-inherit border-0 border-r p-2" class="text-inherit dark:text-inherit border-0 border-r p-2"
disabled={(cursor?.back == undefined && cursor?.next != undefined) || disabled={(cursor?.back == undefined && cursor?.next != undefined) ||
page <= 1} page <= 1}
data-sveltekit-preload-data="off"
> >
{#snippet suffix()} {#snippet suffix()}
<Icon src={ChevronLeft} size="24" mini /> <Icon src={ChevronLeft} size="24" mini />
@@ -95,7 +94,6 @@
rounding="none" rounding="none"
class="text-inherit dark:text-inherit border-0 border-l p-2" class="text-inherit dark:text-inherit border-0 border-l p-2"
disabled={!hasMore} disabled={!hasMore}
data-sveltekit-preload-data="off"
> >
{#snippet suffix()} {#snippet suffix()}
<Icon src={ChevronRight} size="24" mini /> <Icon src={ChevronRight} size="24" mini />
+35 -31
View File
@@ -35,43 +35,47 @@
<svelte:window {onscroll} /> <svelte:window {onscroll} />
{@render children?.()} {@render children?.()}
<div <div class="min-h-screen flex flex-col">
class={[ <div
'fixed lg:sticky bottom-0 lg:top-0', class={[
!dockVisible && 'max-lg:-bottom-24', 'fixed lg:sticky bottom-0 lg:top-0',
'max-w-3xl p-4 left-1/2 -translate-x-1/2 lg:max-w-full lg:p-0 lg:left-0 lg:translate-x-0', !dockVisible && 'max-lg:-bottom-24',
'w-full z-50 pointer-events-none', 'max-w-3xl p-4 left-1/2 -translate-x-1/2 lg:max-w-full lg:p-0 lg:left-0 lg:translate-x-0',
]} 'w-full z-50 pointer-events-none',
style="transition: bottom .4s cubic-bezier(0.075, 0.82, 0.165, 1);" ]}
> style="transition: bottom .4s cubic-bezier(0.075, 0.82, 0.165, 1);"
{@render navbar?.({ aria-hidden="true"
class: [ >
'bg-slate-100/70 dark:bg-zinc-950/90 border-slate-200/50 dark:border-zinc-900', {@render navbar?.({
'pointer-events-auto backdrop-blur-xl border lg:border-t-0 lg:border-x-0', class: [
'rounded-full lg:rounded-none', 'bg-slate-100/70 dark:bg-zinc-950/90 border-slate-200/50 dark:border-zinc-900',
], 'pointer-events-auto backdrop-blur-xl border lg:border-t-0 lg:border-x-0',
style: '', 'rounded-full lg:rounded-none',
})} ],
</div> style: '',
<div class={['content flex-1', settings.newWidth && 'limit-width']}> })}
{@render sidebar?.({ </div>
class: `hidden md:flex sticky top-0 lg:top-16 left-0 h-max bg-slate-100 dark:bg-zinc-950 z-40 max-h-[calc(100vh-4rem)] min-h-[calc(100vh-4rem)]`, <div class={['content flex-1', settings.newWidth && 'limit-width']}>
style: 'grid-area: sidebar; width: 100% !important;', {@render sidebar?.({
})} class: `hidden md:flex sticky top-0 lg:top-16 left-0 max-h-[calc(100vh-4rem)] bg-slate-100 dark:bg-zinc-950 z-40`,
{@render main?.({ style: 'grid-area: sidebar; width: 100% !important;',
class: `w-full bg-slate-50 dark:bg-zinc-925 justify-self-center border-x border-slate-200 dark:border-zinc-900 max-lg:pb-22 pb-3 sm:pb-6`, })}
style: 'grid-area: main', {@render main?.({
})} class: `w-full bg-slate-50 dark:bg-zinc-925 justify-self-center border-x border-slate-200 dark:border-zinc-900 max-lg:pb-22 pb-3 sm:pb-6`,
{@render suffix?.({ style: 'grid-area: main',
class: `max-lg:hidden w-full sticky lg:top-16 h-max max-h-screen overflow-auto left-0 bg-slate-100 dark:bg-zinc-950 z-40`, })}
style: 'grid-area: suffix;', {@render suffix?.({
})} class: `max-lg:hidden w-full sticky lg:top-16 h-max max-h-screen overflow-auto left-0 bg-slate-100 dark:bg-zinc-950 z-40`,
style: 'grid-area: suffix;',
})}
</div>
</div> </div>
<style> <style>
.content { .content {
width: 100%; width: 100%;
display: grid; display: grid;
height: 100%;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
grid-area: content; grid-area: content;
@@ -1,4 +1,6 @@
<script lang="ts"> <script lang="ts">
import { t } from '$lib/i18n/translations'
const sizes = { const sizes = {
sm: 'text-2xl', sm: 'text-2xl',
md: 'text-3xl', md: 'text-3xl',
@@ -25,7 +27,7 @@
}: Props = $props() }: Props = $props()
</script> </script>
<div <header
class={[ class={[
pageHeader && pageHeader &&
`w-[calc(100%+1.5rem)] sm:w-[calc(100%+3rem)] `w-[calc(100%+1.5rem)] sm:w-[calc(100%+3rem)]
@@ -33,6 +35,7 @@
border-b border-slate-200 dark:border-zinc-900 margin z-0`, border-b border-slate-200 dark:border-zinc-900 margin z-0`,
]} ]}
{style} {style}
aria-label={$t('aria.element.pageHeader')}
> >
<h1 <h1
class={[sizes[size], 'flex gap-2 w-full tracking-tight font-medium', clazz]} class={[sizes[size], 'flex gap-2 w-full tracking-tight font-medium', clazz]}
@@ -44,4 +47,4 @@
{@render extended?.()} {@render extended?.()}
</div> </div>
{/if} {/if}
</div> </header>
@@ -32,6 +32,7 @@
size="md" size="md"
rounding="xl" rounding="xl"
class="flex flex-row gap-2 items-center" class="flex flex-row gap-2 items-center"
aria-label={$t('aria.sidebar.accounts')}
> >
{#snippet prefix()} {#snippet prefix()}
<Avatar <Avatar
+5 -1
View File
@@ -35,7 +35,11 @@
let { style = '', class: clazz = '' }: Props = $props() let { style = '', class: clazz = '' }: Props = $props()
</script> </script>
<nav class={['flex flex-col overflow-auto gap-1', clazz]} {style}> <nav
aria-label={$t('aria.sidebar.title')}
class={['flex flex-col overflow-auto gap-1', clazz]}
{style}
>
<ProfileSelection profiles={profile.meta.profiles} /> <ProfileSelection profiles={profile.meta.profiles} />
<EndPlaceholder size="xs">{$t('profile.profile')}</EndPlaceholder> <EndPlaceholder size="xs">{$t('profile.profile')}</EndPlaceholder>
{#if profile.current?.jwt} {#if profile.current?.jwt}
+8
View File
@@ -945,6 +945,14 @@
"upvotes": "{{default}} upvotes", "upvotes": "{{default}} upvotes",
"downvotes": "{{default}} downvotes", "downvotes": "{{default}} downvotes",
"score": "Score: {{default}}" "score": "Score: {{default}}"
},
"sidebar": {
"title": "Sidebar",
"accounts": "Accounts selector"
},
"loading": "Loading",
"element": {
"pageHeader": "Page header"
} }
}, },
"stats": { "stats": {
+2
View File
@@ -18,6 +18,8 @@
stroke-linejoin="round" stroke-linejoin="round"
class="animate-spin" class="animate-spin"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
aria-live="polite"
role="status"
> >
<line x1="12" y1="2" x2="12" y2="6"></line> <line x1="12" y1="2" x2="12" y2="6"></line>
<line x1="12" y1="18" x2="12" y2="22"></line> <line x1="12" y1="18" x2="12" y2="22"></line>
+2 -1
View File
@@ -45,7 +45,7 @@
none: '', none: '',
} }
interface Props extends HTMLAttributes<HTMLDivElement> { interface Props extends HTMLAttributes<HTMLElement> {
elevation?: Elevation elevation?: Elevation
padding?: Padding padding?: Padding
rounding?: Rounding rounding?: Rounding
@@ -53,6 +53,7 @@
element?: string element?: string
class?: ClassValue class?: ClassValue
children?: import('svelte').Snippet children?: import('svelte').Snippet
[key: string]: any
} }
let { let {
+21 -19
View File
@@ -130,7 +130,7 @@
<ModalContainer /> <ModalContainer />
{#snippet sidebar({ style: s, class: c })} {#snippet sidebar({ style: s, class: c })}
<Sidebar class={[c, 'p-3 sm:p-6']} style={s} /> <Sidebar class={[c, 'p-3 sm:p-6 w-full']} style={s} />
{/snippet} {/snippet}
{#snippet main({ style: s, class: c })} {#snippet main({ style: s, class: c })}
<main <main
@@ -144,23 +144,25 @@
{#snippet navbar({ style: s, class: c })} {#snippet navbar({ style: s, class: c })}
<Navbar class={c} style={s} /> <Navbar class={c} style={s} />
{/snippet} {/snippet}
{#snippet suffix({ class: c, style: s })} {#snippet suffix({ class: c })}
<div class={[c, 'p-3 sm:p-6']} style={s}> {#if page.data.slots?.sidebar?.component}
{#if page.data.slots?.sidebar?.component} {@const SvelteComponent = page.data.slots.sidebar.component}
{@const SvelteComponent = page.data.slots.sidebar.component} <SvelteComponent
<SvelteComponent {...page.data.slots.sidebar.props} /> {...page.data.slots.sidebar.props}
{:else if site.data} class={[c, 'p-3 sm:p-6']}
<SiteCard />
site={site.data.site_view} {:else if site.data}
taglines={site.data.taglines} <SiteCard
admins={site.data.admins} site={site.data.site_view}
version={site.data.version} taglines={site.data.taglines}
/> admins={site.data.admins}
{:else} version={site.data.version}
<div class="h-64 w-full grid place-items-center"> class={[c, 'p-3 sm:p-6']}
<Spinner width={32} /> />
</div> {:else}
{/if} <div class="h-64 w-full grid place-items-center">
</div> <Spinner width={32} />
</div>
{/if}
{/snippet} {/snippet}
</Shell> </Shell>
+17 -23
View File
@@ -36,31 +36,25 @@
</svelte:head> </svelte:head>
<div class="flex flex-col gap-2 max-w-full w-full min-w-0"> <div class="flex flex-col gap-2 max-w-full w-full min-w-0">
<header class="flex flex-col gap-4 relative"> <Header pageHeader>
<Header pageHeader> {$t('routes.frontpage.title')}
{$t('routes.frontpage.title')}
{#snippet extended()} {#snippet extended()}
<form class="flex items-center gap-2" method="get" action="/"> <form class="flex items-center gap-2" method="get" action="/">
{#if type} {#if type}
<Location name="type" navigate bind:selected={type} /> <Location name="type" navigate bind:selected={type} />
{/if} {/if}
<Sort placement="bottom" name="sort" navigate bind:selected={sort} /> <Sort placement="bottom" name="sort" navigate bind:selected={sort} />
<ViewSelect placement="bottom" /> <ViewSelect placement="bottom" />
<noscript> <noscript>
<Button <Button class="self-end h-[34px] aspect-square" size="custom" submit>
class="self-end h-[34px] aspect-square" <Icon src={ArrowRight} size="16" micro />
size="custom" </Button>
submit </noscript>
> </form>
<Icon src={ArrowRight} size="16" micro /> {/snippet}
</Button> </Header>
</noscript>
</form>
{/snippet}
</Header>
</header>
<FeedComponent <FeedComponent
bind:posts={data.feed.value.posts.posts} bind:posts={data.feed.value.posts.posts}