aria: improve semantics
This commit is contained in:
19 files changed
+175
-172
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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}
|
||||
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
@@ -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,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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user