Skip to content

Commit 758214d

Browse files
zersiaxnekename
andcommitted
feat: add dialog semantics and accessible labels to popups and the plugin manager (#294)
Co-authored-by: nekename <63245705+nekename@users.noreply.github.com>
1 parent 37648f8 commit 758214d

7 files changed

Lines changed: 45 additions & 16 deletions

File tree

src/components/ActionList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
role="option"
118118
aria-selected="false"
119119
tabindex={i == 0 ? 0 : -1}
120-
aria-label="{$localisations?.[action.plugin]?.[action.uuid]?.Name ?? action.name}: {$localisations?.[action.plugin]?.[action.uuid]?.Tooltip ?? action.tooltip}"
120+
aria-label={$localisations?.[action.plugin]?.[action.uuid]?.Name ?? action.name}
121121
on:dragstart={(event) => {
122122
if (!event.dataTransfer) return;
123123
event.dataTransfer.effectAllowed = "copy";

src/components/ListedPlugin.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
export let hidden: boolean = false;
66
export let disconnected: boolean = false;
77
export let action: () => void;
8+
export let actionLabel: string = "";
89
export let secondaryAction: (() => void) | undefined = undefined;
10+
export let secondaryActionLabel: string = "";
911
</script>
1012

1113
<div
@@ -20,11 +22,11 @@
2022

2123
<div class="flex flex-col ml-auto mr-4">
2224
{#if secondaryAction}
23-
<button on:click={secondaryAction}>
25+
<button on:click={secondaryAction} aria-label={secondaryActionLabel}>
2426
<slot name="secondary" />
2527
</button>
2628
{/if}
27-
<button on:click={action}>
29+
<button on:click={action} aria-label={actionLabel}>
2830
<slot />
2931
</button>
3032
</div>

src/components/PluginDetails.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
});
7171
</script>
7272

73-
<Popup show>
74-
<button class="mr-2 my-1 float-right text-xl text-neutral-300" on:click={close}>✕</button>
73+
<Popup show label="{details.name} plugin details">
74+
<button class="mr-2 my-1 float-right text-xl text-neutral-300" on:click={close} aria-label="Close">✕</button>
7575
<div class="flex flex-row items-start">
7676
<img
7777
src={"https://openactionapi.github.io/plugins/icons/" + id + ".png"}
@@ -111,6 +111,7 @@
111111
<button
112112
on:click={() => invoke("open_url", { url: details.download_url ?? details.repository + "/releases/latest" })}
113113
class="ml-1 p-3.5 active:translate-y-0.5 text-lg text-neutral-100 bg-indigo-600 hover:bg-indigo-500 transition-colors border border-indigo-500 rounded-r-lg"
114+
aria-label="Download latest release from GitHub"
114115
>
115116
<ArrowSquareOut size={24} />
116117
</button>

src/components/PluginManager.svelte

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@
212212
}}
213213
/>
214214

215-
<Popup show={showPopup}>
216-
<button class="mr-2 my-1 float-right text-xl text-neutral-300" on:click={() => showPopup = false}>✕</button>
215+
<Popup show={showPopup} label="Manage plugins">
216+
<button class="mr-2 my-1 float-right text-xl text-neutral-300" on:click={() => showPopup = false} aria-label="Close">✕</button>
217217
<h2 class="m-2 font-semibold text-xl text-neutral-300">Manage plugins</h2>
218218

219219
<h2 class="mx-2 mt-6 mb-2 text-lg text-neutral-400">Installed plugins</h2>
@@ -235,10 +235,9 @@
235235
if ($settings?.developer) invoke("reload_plugin", { id: plugin.id });
236236
else removePlugin(plugin);
237237
}}
238-
secondaryAction={() => {
239-
if (!plugin.registered) invoke("open_log_directory");
240-
else if (plugin.has_settings_interface) invoke("show_settings_interface", { plugin: plugin.id });
241-
}}
238+
actionLabel={$settings?.developer ? "Reload" : "Remove"}
239+
secondaryAction={!plugin.registered ? () => invoke("open_log_directory") : plugin.has_settings_interface ? () => invoke("show_settings_interface", { plugin: plugin.id }) : undefined}
240+
secondaryActionLabel={!plugin.registered ? "View logs" : "Settings"}
242241
>
243242
<svelte:fragment slot="subtitle">
244243
{plugin.version}
@@ -295,6 +294,7 @@
295294
bind:value={query}
296295
class="w-full p-2 text-neutral-300"
297296
placeholder="Search plugins"
297+
aria-label="Search plugins"
298298
type="search"
299299
spellcheck="false"
300300
/>
@@ -315,6 +315,7 @@
315315
subtitle={plugin.author}
316316
hidden={!plugin.name.toLowerCase().includes(query.toLowerCase())}
317317
action={() => openDetailsView = id}
318+
actionLabel="View details"
318319
>
319320
<ArrowSquareOut size="24" class="text-neutral-400" />
320321
</ListedPlugin>
@@ -347,6 +348,7 @@
347348
subtitle={plugin.author}
348349
hidden={!plugin.name.toLowerCase().includes(query.toLowerCase())}
349350
action={() => installPluginElgato(plugin)}
351+
actionLabel="Install"
350352
>
351353
<CloudArrowDown size="24" class="text-neutral-400" />
352354
</ListedPlugin>
@@ -372,7 +374,9 @@
372374
download_url: undefined,
373375
});
374376
}}
377+
actionLabel="Install"
375378
secondaryAction={() => window.open("https://tacto.live")}
379+
secondaryActionLabel="Visit website"
376380
>
377381
<svelte:fragment slot="secondary">
378382
<ArrowSquareOut size="24" class="text-neutral-400" />
@@ -400,7 +404,7 @@
400404
<div class="fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 mt-2 p-2 w-96 text-xs text-neutral-300 bg-neutral-700 border border-neutral-600 rounded-lg z-40">
401405
<h3 class="mb-2 font-semibold text-lg text-center">Choose a release asset</h3>
402406
<div class="select-wrapper">
403-
<select class="w-full bg-neutral-800!" bind:value={choice}>
407+
<select class="w-full bg-neutral-800!" bind:value={choice} aria-label="Release asset">
404408
{#each choices as choice, i}
405409
<option value={i}>{choice.name}</option>
406410
{/each}

src/components/Popup.svelte

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
<script lang="ts">
2+
import { onDestroy, tick } from "svelte";
3+
24
export let show = false;
5+
export let label = "";
6+
7+
let popupEl: HTMLDivElement;
8+
let previousFocus: HTMLElement | null = null;
9+
10+
$: if (show) {
11+
previousFocus = document.activeElement as HTMLElement | null;
12+
tick().then(() => popupEl?.focus());
13+
} else if (previousFocus) {
14+
previousFocus.focus();
15+
previousFocus = null;
16+
}
17+
18+
onDestroy(() => previousFocus?.focus());
319
</script>
420

521
{#if show}
6-
<div class="absolute top-0 left-0 m-2 p-4 w-[calc(100%-1rem)] h-[calc(100%-1rem)] bg-neutral-800 border border-neutral-700 rounded-lg overflow-auto z-30">
22+
<div
23+
bind:this={popupEl}
24+
class="absolute top-0 left-0 m-2 p-4 w-[calc(100%-1rem)] h-[calc(100%-1rem)] bg-neutral-800 border border-neutral-700 rounded-lg overflow-auto z-30"
25+
role="dialog"
26+
tabindex="-1"
27+
aria-label={label}
28+
>
729
<slot />
830
</div>
931
{/if}

src/components/ProfileManager.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
}}
201201
/>
202202

203-
<Popup show={showPopup}>
203+
<Popup show={showPopup} label="{device.name} profiles">
204204
<button class="mr-1 float-right text-xl text-neutral-300" on:click={() => showPopup = false} aria-label="Close">✕</button>
205205
<h2 class="text-xl font-semibold text-neutral-300">{device.name}</h2>
206206

@@ -278,7 +278,7 @@
278278
</div>
279279
</Popup>
280280

281-
<Popup show={showApplicationManager}>
281+
<Popup show={showApplicationManager} label="Application profiles">
282282
<button class="mr-1 float-right text-xl text-neutral-300" on:click={() => showApplicationManager = false} aria-label="Close">✕</button>
283283
<h2 class="text-xl font-semibold text-neutral-300">{device.name}</h2>
284284
<span class="text-sm text-neutral-400">If your application isn't listed, try switching to it and back again.</span>

src/components/SettingsView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
}}
4646
/>
4747

48-
<Popup show={showPopup}>
48+
<Popup show={showPopup} label="Settings">
4949
<button class="mr-2 my-1 float-right text-xl text-neutral-300" on:click={() => showPopup = false} aria-label="Close">✕</button>
5050
<h2 class="m-2 font-semibold text-xl text-neutral-300">Settings</h2>
5151
{#if $settings}

0 commit comments

Comments
 (0)