feat(web,a11y): form and search filter accessibility (#9087)

* feat(web,a11y): search filter accessibility

- visible focus rings
- labels for text search
- responsive buttons / radio buttons / checkboxes
- buttons to lowercase
- add fieldsets to radio buttons and checkboxes, so the screen reader
  announces the label for the group

* feat: extract inputs into reusable components, replace all checkboxes

* chore: revert changes to responsive buttons

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Ben 2024-04-26 06:18:19 +00:00 committed by GitHub
parent 00d186ec52
commit 53d571d29e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 102 additions and 112 deletions

View file

@ -7,26 +7,18 @@
</script>
<script lang="ts">
import Checkbox from '$lib/components/elements/checkbox.svelte';
export let filters: SearchDisplayFilters;
</script>
<div id="display-options-selection" class="text-sm">
<p class="immich-form-label">DISPLAY OPTIONS</p>
<div class="flex flex-wrap gap-x-5 gap-y-2 mt-1">
<label class="flex items-center gap-2">
<input type="checkbox" class="size-5 flex-shrink-0" bind:checked={filters.isNotInAlbum} />
<span class="pt-1">Not in any album</span>
</label>
<label class="flex items-center gap-2">
<input type="checkbox" class="size-5 flex-shrink-0" bind:checked={filters.isArchive} />
<span class="pt-1">Archive</span>
</label>
<label class="flex items-center gap-2">
<input type="checkbox" class="size-5 flex-shrink-0" bind:checked={filters.isFavorite} />
<span class="pt-1">Favorite</span>
</label>
</div>
<div id="display-options-selection">
<fieldset>
<legend class="immich-form-label">DISPLAY OPTIONS</legend>
<div class="flex flex-wrap gap-x-5 gap-y-2 mt-1">
<Checkbox id="not-in-album-checkbox" label="Not in any album" bind:checked={filters.isNotInAlbum} />
<Checkbox id="archive-checkbox" label="Archive" bind:checked={filters.isArchive} />
<Checkbox id="favorite-checkbox" label="Favorite" bind:checked={filters.isFavorite} />
</div>
</fieldset>
</div>

View file

@ -124,7 +124,7 @@
on:submit|preventDefault={search}
on:reset|preventDefault={resetForm}
>
<div class="px-4 sm:px-6 py-4 space-y-10 max-h-[calc(100dvh-12rem)] overflow-y-auto immich-scrollbar">
<div class="px-4 sm:px-6 py-4 space-y-10 max-h-[calc(100dvh-12rem)] overflow-y-auto immich-scrollbar" tabindex="-1">
<!-- PEOPLE -->
<SearchPeopleSection width={filterBoxWidth} bind:selectedPeople={filter.personIds} />
@ -153,8 +153,8 @@
id="button-row"
class="flex justify-end gap-4 border-t dark:border-gray-800 dark:bg-immich-dark-gray px-4 sm:py-6 py-4 mt-2 rounded-b-3xl"
>
<Button type="reset" color="gray">CLEAR ALL</Button>
<Button type="submit">SEARCH</Button>
<Button type="reset" color="gray">Clear all</Button>
<Button type="submit">Search</Button>
</div>
</form>
</div>

View file

@ -1,47 +1,17 @@
<script lang="ts">
import RadioButton from '$lib/components/elements/radio-button.svelte';
import { MediaType } from './search-filter-box.svelte';
export let filteredMedia: MediaType;
</script>
<div id="media-type-selection">
<p class="immich-form-label">MEDIA TYPE</p>
<div class="flex gap-5 mt-1 text-base">
<label for="type-all" class="flex items-center gap-1">
<input
bind:group={filteredMedia}
value={MediaType.All}
type="radio"
name="radio-type"
id="type-all"
class="size-4"
/>
<span class="pt-0.5">All</span>
</label>
<label for="type-image" class="flex items-center gap-1">
<input
bind:group={filteredMedia}
value={MediaType.Image}
type="radio"
name="media-type"
id="type-image"
class="size-4"
/>
<span class="pt-0.5">Image</span>
</label>
<label for="type-video" class="flex items-center gap-1">
<input
bind:group={filteredMedia}
value={MediaType.Video}
type="radio"
name="radio-type"
id="type-video"
class="size-4"
/>
<span class="pt-0.5">Video</span>
</label>
</div>
<fieldset>
<legend class="immich-form-label">MEDIA TYPE</legend>
<div class="flex flex-wrap gap-x-5 gap-y-2 mt-1">
<RadioButton name="media-type" id="type-all" bind:group={filteredMedia} label="All" value={MediaType.All} />
<RadioButton name="media-type" id="type-image" bind:group={filteredMedia} label="Image" value={MediaType.Image} />
<RadioButton name="media-type" id="type-video" bind:group={filteredMedia} label="Video" value={MediaType.Video} />
</div>
</fieldset>
</div>

View file

@ -91,10 +91,10 @@
on:click={() => (showAllPeople = !showAllPeople)}
>
{#if showAllPeople}
<span><Icon path={mdiClose} /></span>
<span><Icon path={mdiClose} ariaHidden /></span>
Collapse
{:else}
<span><Icon path={mdiArrowRight} /></span>
<span><Icon path={mdiArrowRight} ariaHidden /></span>
See all people
{/if}
</Button>

View file

@ -1,4 +1,6 @@
<script lang="ts">
import RadioButton from '$lib/components/elements/radio-button.svelte';
export let filename: string | undefined;
export let context: string | undefined;
@ -18,40 +20,45 @@
}
</script>
<div class="flex gap-5">
<label class="immich-form-label" for="context">
<input type="radio" name="context" id="context" bind:group={selectedOption} value={TextSearchOptions.Context} />
<span>CONTEXT</span>
</label>
<label class="immich-form-label" for="file-name">
<input
type="radio"
name="file-name"
id="file-name"
<fieldset>
<legend class="immich-form-label">Search type</legend>
<div class="flex flex-wrap gap-x-5 gap-y-2 mt-1 mb-2">
<RadioButton
name="query-type"
id="context-radio"
bind:group={selectedOption}
label="Context"
value={TextSearchOptions.Context}
/>
<RadioButton
name="query-type"
id="file-name-radio"
bind:group={selectedOption}
label="File name or extension"
value={TextSearchOptions.Filename}
/>
<span>FILE NAME</span>
</label>
</div>
</div>
</fieldset>
{#if selectedOption === TextSearchOptions.Context}
<label for="context-input" class="immich-form-label">Search by context</label>
<input
class="immich-form-input hover:cursor-text w-full !mt-1"
type="text"
id="context"
id="context-input"
name="context"
placeholder="Sunrise on the beach"
bind:value={context}
/>
{:else}
<label for="file-name-input" class="immich-form-label">Search by file name or extension</label>
<input
class="immich-form-input hover:cursor-text w-full !mt-1"
type="text"
id="file-name"
id="file-name-input"
name="file-name"
placeholder="File name or extension i.e. IMG_1234.JPG or PNG"
placeholder="i.e. IMG_1234.JPG or PNG"
bind:value={filename}
aria-labelledby="file-name-label"
/>
{/if}

View file

@ -1,4 +1,5 @@
<script lang="ts">
import Checkbox from '$lib/components/elements/checkbox.svelte';
import { quintOut } from 'svelte/easing';
import { fly } from 'svelte/transition';
@ -34,17 +35,16 @@
{desc}
</p>
{/if}
{#each options as option}
<label class="flex items-center mb-2">
<input
type="checkbox"
class="form-checkbox h-5 w-5 color"
{disabled}
<div class="flex flex-col gap-2">
{#each options as option}
<Checkbox
id="{option.value}-checkbox"
label={option.text}
checked={value.includes(option.value)}
{disabled}
labelClass="text-gray-500 dark:text-gray-300"
on:change={() => handleCheckboxChange(option.value)}
/>
<span class="ml-2 text-sm text-gray-500 dark:text-gray-300 pt-1">{option.text}</span>
</label>
{/each}
{/each}
</div>
</div>