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 -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>
</div>
<div
style="display: contents;"
>
<div style="display: contents;">
%sveltekit.body%
</div>
</body>
+1 -1
View File
@@ -237,7 +237,7 @@ class Profile {
const id = Math.max(...this.meta.profiles.map(p => p.id)) + 1
this.meta.profile = id
this.meta.profiles.push({
this.meta.profiles.unshift({
id: id,
instance: instance,
jwt: jwt,
+5 -4
View File
@@ -12,13 +12,14 @@
import LabelStat from '../ui/LabelStat.svelte'
import ItemList from './generic/ItemList.svelte'
import { optimizeImageURL } from './post/helpers'
import type { ClassValue } from 'svelte/elements'
interface Props {
interface Props extends HTMLDivElement {
site: SiteView
taglines?: Tagline[] | undefined
admins?: PersonView[] | undefined
version?: string | undefined
class?: string
class?: ClassValue
}
let {
@@ -30,7 +31,7 @@
}: Props = $props()
</script>
<div
<aside
class={[
'w-full text-slate-600 dark:text-zinc-400 flex flex-col gap-4 text-sm',
clazz,
@@ -140,4 +141,4 @@
</Link>
</div>
</div>
</div>
</aside>
@@ -146,11 +146,15 @@
</script>
{#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} />
</div>
{:then community_view}
<div
<aside
class={[
'min-w-full pt-0 text-slate-600 dark:text-zinc-400 flex flex-col gap-4 text-sm',
clazz,
@@ -337,5 +341,5 @@
{/if}
</Menu>
</div>
</div>
</aside>
{/await}
+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}
+5 -5
View File
@@ -40,14 +40,14 @@
clazz,
]}
>
<span class="font-medium text-left">
<h3 class="font-medium text-left">
{@render children?.()}
</span>
<hr
</h3>
<div
class={[
'flex-1 border-slate-200 dark:border-zinc-800',
'flex-1 border-slate-200 dark:border-zinc-800 border-b',
!border && 'opacity-0',
]}
/>
></div>
{@render action?.()}
</div>
-2
View File
@@ -63,7 +63,6 @@
class="text-inherit dark:text-inherit border-0 border-r p-2"
disabled={(cursor?.back == undefined && cursor?.next != undefined) ||
page <= 1}
data-sveltekit-preload-data="off"
>
{#snippet suffix()}
<Icon src={ChevronLeft} size="24" mini />
@@ -95,7 +94,6 @@
rounding="none"
class="text-inherit dark:text-inherit border-0 border-l p-2"
disabled={!hasMore}
data-sveltekit-preload-data="off"
>
{#snippet suffix()}
<Icon src={ChevronRight} size="24" mini />
+35 -31
View File
@@ -35,43 +35,47 @@
<svelte:window {onscroll} />
{@render children?.()}
<div
class={[
'fixed lg:sticky bottom-0 lg:top-0',
!dockVisible && 'max-lg:-bottom-24',
'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);"
>
{@render navbar?.({
class: [
'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',
'rounded-full lg:rounded-none',
],
style: '',
})}
</div>
<div class={['content flex-1', settings.newWidth && 'limit-width']}>
{@render sidebar?.({
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)]`,
style: 'grid-area: sidebar; width: 100% !important;',
})}
{@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`,
style: 'grid-area: main',
})}
{@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 class="min-h-screen flex flex-col">
<div
class={[
'fixed lg:sticky bottom-0 lg:top-0',
!dockVisible && 'max-lg:-bottom-24',
'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);"
aria-hidden="true"
>
{@render navbar?.({
class: [
'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',
'rounded-full lg:rounded-none',
],
style: '',
})}
</div>
<div class={['content flex-1', settings.newWidth && 'limit-width']}>
{@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`,
style: 'grid-area: sidebar; width: 100% !important;',
})}
{@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`,
style: 'grid-area: main',
})}
{@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>
<style>
.content {
width: 100%;
display: grid;
height: 100%;
margin-left: auto;
margin-right: auto;
grid-area: content;
@@ -1,4 +1,6 @@
<script lang="ts">
import { t } from '$lib/i18n/translations'
const sizes = {
sm: 'text-2xl',
md: 'text-3xl',
@@ -25,7 +27,7 @@
}: Props = $props()
</script>
<div
<header
class={[
pageHeader &&
`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`,
]}
{style}
aria-label={$t('aria.element.pageHeader')}
>
<h1
class={[sizes[size], 'flex gap-2 w-full tracking-tight font-medium', clazz]}
@@ -44,4 +47,4 @@
{@render extended?.()}
</div>
{/if}
</div>
</header>
@@ -32,6 +32,7 @@
size="md"
rounding="xl"
class="flex flex-row gap-2 items-center"
aria-label={$t('aria.sidebar.accounts')}
>
{#snippet prefix()}
<Avatar
+5 -1
View File
@@ -35,7 +35,11 @@
let { style = '', class: clazz = '' }: Props = $props()
</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} />
<EndPlaceholder size="xs">{$t('profile.profile')}</EndPlaceholder>
{#if profile.current?.jwt}
+8
View File
@@ -945,6 +945,14 @@
"upvotes": "{{default}} upvotes",
"downvotes": "{{default}} downvotes",
"score": "Score: {{default}}"
},
"sidebar": {
"title": "Sidebar",
"accounts": "Accounts selector"
},
"loading": "Loading",
"element": {
"pageHeader": "Page header"
}
},
"stats": {
+2
View File
@@ -18,6 +18,8 @@
stroke-linejoin="round"
class="animate-spin"
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="18" x2="12" y2="22"></line>
+2 -1
View File
@@ -45,7 +45,7 @@
none: '',
}
interface Props extends HTMLAttributes<HTMLDivElement> {
interface Props extends HTMLAttributes<HTMLElement> {
elevation?: Elevation
padding?: Padding
rounding?: Rounding
@@ -53,6 +53,7 @@
element?: string
class?: ClassValue
children?: import('svelte').Snippet
[key: string]: any
}
let {
+21 -19
View File
@@ -130,7 +130,7 @@
<ModalContainer />
{#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 main({ style: s, class: c })}
<main
@@ -144,23 +144,25 @@
{#snippet navbar({ style: s, class: c })}
<Navbar class={c} style={s} />
{/snippet}
{#snippet suffix({ class: c, style: s })}
<div class={[c, 'p-3 sm:p-6']} style={s}>
{#if page.data.slots?.sidebar?.component}
{@const SvelteComponent = page.data.slots.sidebar.component}
<SvelteComponent {...page.data.slots.sidebar.props} />
{:else if site.data}
<SiteCard
site={site.data.site_view}
taglines={site.data.taglines}
admins={site.data.admins}
version={site.data.version}
/>
{:else}
<div class="h-64 w-full grid place-items-center">
<Spinner width={32} />
</div>
{/if}
</div>
{#snippet suffix({ class: c })}
{#if page.data.slots?.sidebar?.component}
{@const SvelteComponent = page.data.slots.sidebar.component}
<SvelteComponent
{...page.data.slots.sidebar.props}
class={[c, 'p-3 sm:p-6']}
/>
{:else if site.data}
<SiteCard
site={site.data.site_view}
taglines={site.data.taglines}
admins={site.data.admins}
version={site.data.version}
class={[c, 'p-3 sm:p-6']}
/>
{:else}
<div class="h-64 w-full grid place-items-center">
<Spinner width={32} />
</div>
{/if}
{/snippet}
</Shell>
+17 -23
View File
@@ -36,31 +36,25 @@
</svelte:head>
<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>
{$t('routes.frontpage.title')}
<Header pageHeader>
{$t('routes.frontpage.title')}
{#snippet extended()}
<form class="flex items-center gap-2" method="get" action="/">
{#if type}
<Location name="type" navigate bind:selected={type} />
{/if}
<Sort placement="bottom" name="sort" navigate bind:selected={sort} />
<ViewSelect placement="bottom" />
{#snippet extended()}
<form class="flex items-center gap-2" method="get" action="/">
{#if type}
<Location name="type" navigate bind:selected={type} />
{/if}
<Sort placement="bottom" name="sort" navigate bind:selected={sort} />
<ViewSelect placement="bottom" />
<noscript>
<Button
class="self-end h-[34px] aspect-square"
size="custom"
submit
>
<Icon src={ArrowRight} size="16" micro />
</Button>
</noscript>
</form>
{/snippet}
</Header>
</header>
<noscript>
<Button class="self-end h-[34px] aspect-square" size="custom" submit>
<Icon src={ArrowRight} size="16" micro />
</Button>
</noscript>
</form>
{/snippet}
</Header>
<FeedComponent
bind:posts={data.feed.value.posts.posts}