Add tabindex to elements for better keyboard navigation

This commit is contained in:
2021-12-06 15:03:41 +01:00
parent 778e15dfbd
commit 8ac954b1a2
9 changed files with 20 additions and 14 deletions

View File

@@ -25,7 +25,7 @@
</script> </script>
{#if tag === 'button'} {#if tag === 'button'}
<button class={classes} on:click disabled={disabled}> <button class={classes} tabindex="0" {disabled} on:click>
<slot /> <slot />
<SplitText {text} clone={true} /> <SplitText {text} clone={true} />
</button> </button>
@@ -35,7 +35,8 @@
{rel} {target} {rel} {target}
sveltekit:prefetch={url && isExternal ? null : true} sveltekit:prefetch={url && isExternal ? null : true}
sveltekit:noscroll={isExternal ? null : true} sveltekit:noscroll={isExternal ? null : true}
disabled={disabled} {disabled}
tabindex="0"
on:click on:click
> >
<slot /> <slot />

View File

@@ -18,7 +18,7 @@
</script> </script>
{#if tag === 'a'} {#if tag === 'a'}
<a href={url} class={classes} on:click> <a href={url} class={classes} tabindex="0" on:click>
{#if clone} {#if clone}
{#each Array(2) as _} {#each Array(2) as _}
<slot /> <slot />
@@ -28,7 +28,7 @@
{/if} {/if}
</a> </a>
{:else} {:else}
<button {type} {form} class={classes} disabled={disabled} on:click> <button {type} {form} class={classes} disabled={disabled} tabindex="0" on:click>
{#if clone} {#if clone}
{#each Array(2) as _} {#each Array(2) as _}
<slot /> <slot />

View File

@@ -63,6 +63,7 @@
on:mousemove={handleMouseMove} on:mousemove={handleMouseMove}
on:mouseleave={handleMouseLeave} on:mouseleave={handleMouseLeave}
sveltekit:noscroll sveltekit:noscroll
tabindex="0"
> >
<Image <Image
class="location__flag" class="location__flag"

View File

@@ -71,7 +71,7 @@
</ul> </ul>
</nav> </nav>
<button class="switcher__button" title="{!isOpen ? 'Open' : 'Close'} menu" <button class="switcher__button" title="{!isOpen ? 'Open' : 'Close'} menu" tabindex="0"
on:click={toggleSwitcher} on:click={toggleSwitcher}
> >
<span> <span>

View File

@@ -10,7 +10,7 @@
<footer class="footer"> <footer class="footer">
<div class="container grid"> <div class="container grid">
<a href="/" class="footer__title" sveltekit:prefetch sveltekit:noscroll> <a href="/" class="footer__title" sveltekit:prefetch sveltekit:noscroll tabindex="0">
<SiteTitle tag="div" /> <SiteTitle tag="div" />
</a> </a>
@@ -18,7 +18,7 @@
<ul> <ul>
{#each footer_links as { title, slug }} {#each footer_links as { title, slug }}
<li> <li>
<a href="/{slug}" class="link-3d" sveltekit:prefetch sveltekit:noscroll> <a href="/{slug}" class="link-3d" sveltekit:prefetch sveltekit:noscroll tabindex="0">
<SplitText text={title} clone={true} /> <SplitText text={title} clone={true} />
</a> </a>
</li> </li>

View File

@@ -276,7 +276,7 @@
</p> </p>
</div> </div>
<figure class="house__photo"> <figure class="house__photo">
<a href="/{params.country}/{params.location}/{slug}" sveltekit:prefetch sveltekit:noscroll> <a href="/{params.country}/{params.location}/{slug}" sveltekit:noscroll tabindex="0">
<Image <Image
id={id} id={id}
sizeKey="photo-list" sizeKey="photo-list"
@@ -300,7 +300,11 @@
<section class="location-page__next"> <section class="location-page__next">
<div class="container"> <div class="container">
<div class="pagination" role="button" on:click={!ended && loadMorePhotos} disabled={ended ? ended : undefined}> <div class="pagination" role="button"
on:click={!ended && loadMorePhotos} disabled={ended ? ended : undefined}
on:keydown={({ key, target }) => key === 'Enter' && target.click()}
tabindex="0"
>
<div class="pagination__progress"> <div class="pagination__progress">
<span class="current">{currentPhotosAmount}</span> <span class="current">{currentPhotosAmount}</span>
<span>/</span> <span>/</span>

View File

@@ -32,7 +32,7 @@
<dt> <dt>
{#if website} {#if website}
<h3> <h3>
<a href={website} rel="noopener external" target="_blank">{name}</a> <a href={website} rel="noopener external" target="_blank" tabindex="0">{name}</a>
</h3> </h3>
{:else} {:else}
<h3>{name}</h3> <h3>{name}</h3>
@@ -57,7 +57,7 @@
<dt> <dt>
{#if website} {#if website}
<h3> <h3>
<a href={website} rel="noopener external" target="_blank">{name}</a> <a href={website} rel="noopener external" target="_blank" tabindex="0">{name}</a>
</h3> </h3>
{:else} {:else}
<h3>{name}</h3> <h3>{name}</h3>
@@ -67,7 +67,7 @@
<ul> <ul>
{#each location as { location_id: { name, slug: slugLocation, country: { slug: slugCountry }}}, index} {#each location as { location_id: { name, slug: slugLocation, country: { slug: slugCountry }}}, index}
<li> <li>
<a href="/{slugCountry}/{slugLocation}" sveltekit:noscroll>{name}</a> <a href="/{slugCountry}/{slugLocation}" sveltekit:noscroll tabindex="0">
</li> </li>
{/each} {/each}
</ul> </ul>

View File

@@ -421,7 +421,7 @@
<div class="photos__grid" bind:this={photosGridEl}> <div class="photos__grid" bind:this={photosGridEl}>
{#each photos as { id, image, slug, location, title, city }, index (id)} {#each photos as { id, image, slug, location, title, city }, index (id)}
<figure class="photo shadow-photo"> <figure class="photo shadow-photo">
<a href="/{location.country.slug}/{location.slug}/{slug}" sveltekit:prefetch sveltekit:noscroll> <a href="/{location.country.slug}/{location.slug}/{slug}" sveltekit:prefetch sveltekit:noscroll tabindex="0">
<Image <Image
id={image.id} id={image.id}
sizeKey="photo-grid" sizeKey="photo-grid"

View File

@@ -28,7 +28,7 @@
<ul> <ul>
{#each issues as { issue, title, date_sent, link, thumbnail: { id } }} {#each issues as { issue, title, date_sent, link, thumbnail: { id } }}
<li class="issue"> <li class="issue">
<a href={link} target="_blank" rel="external noreferrer noopener"> <a href={link} target="_blank" rel="external noreferrer noopener" tabindex="0">
<Image <Image
id={id} id={id}
sizeKey="issue-thumbnail-small" sizeKey="issue-thumbnail-small"