Skip to content

Commit 218de39

Browse files
committed
fix(a11y): announce more command palette actions
1 parent a7c1e09 commit 218de39

File tree

7 files changed

+73
-8
lines changed

7 files changed

+73
-8
lines changed

app/components/Diff/ViewerPanel.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ function getCodeUrl(version: string): string {
8888
return `/package-code/${props.packageName}/v/${version}/${props.file.path}`
8989
}
9090
91+
const { announce } = useCommandPalette()
92+
9193
useCommandPaletteContextCommands(
9294
computed((): CommandPaletteContextCommandInput[] => [
9395
{
@@ -101,6 +103,14 @@ useCommandPaletteContextCommands(
101103
: $t('command_palette.state.off'),
102104
action: () => {
103105
mergeModifiedLines.value = !mergeModifiedLines.value
106+
announce(
107+
$t(
108+
mergeModifiedLines.value
109+
? 'command_palette.announcements.setting_on'
110+
: 'command_palette.announcements.setting_off',
111+
{ setting: $t('command_palette.diff.merge_modified_lines') },
112+
),
113+
)
104114
},
105115
},
106116
{
@@ -112,6 +122,14 @@ useCommandPaletteContextCommands(
112122
badge: wordWrap.value ? $t('command_palette.state.on') : $t('command_palette.state.off'),
113123
action: () => {
114124
wordWrap.value = !wordWrap.value
125+
announce(
126+
$t(
127+
wordWrap.value
128+
? 'command_palette.announcements.setting_on'
129+
: 'command_palette.announcements.setting_off',
130+
{ setting: $t('command_palette.diff.word_wrap') },
131+
),
132+
)
115133
},
116134
},
117135
]),

app/components/Package/Header.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ function hasProvenance(version: PackumentVersion | null): boolean {
8181
return !!(version.dist as { attestations?: unknown }).attestations
8282
}
8383
84+
const { announce } = useCommandPalette()
85+
8486
useCommandPaletteContextCommands(
8587
computed((): CommandPaletteContextCommandInput[] => {
8688
if (!packageName.value) return []
@@ -94,6 +96,7 @@ useCommandPaletteContextCommands(
9496
iconClass: 'i-lucide:copy',
9597
action: () => {
9698
copyPkgName()
99+
announce($t('command_palette.announcements.copied_to_clipboard'))
97100
},
98101
},
99102
]

app/components/Terminal/Install.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ const copyDevInstallCommand = () =>
125125
}),
126126
)
127127
128+
const { announce } = useCommandPalette()
129+
128130
useCommandPaletteContextCommands(
129131
computed((): CommandPaletteContextCommandInput[] => {
130132
const commands: CommandPaletteContextCommandInput[] = [
@@ -136,6 +138,7 @@ useCommandPaletteContextCommands(
136138
iconClass: 'i-lucide:copy',
137139
action: () => {
138140
copyInstallCommand()
141+
announce($t('command_palette.announcements.copied_to_clipboard'))
139142
},
140143
},
141144
]
@@ -149,6 +152,7 @@ useCommandPaletteContextCommands(
149152
iconClass: 'i-lucide:copy-plus',
150153
action: () => {
151154
copyDevInstallCommand()
155+
announce($t('command_palette.announcements.copied_to_clipboard'))
152156
},
153157
})
154158
}
@@ -162,6 +166,7 @@ useCommandPaletteContextCommands(
162166
iconClass: 'i-lucide:terminal-square',
163167
action: () => {
164168
copyRunCommand(props.executableInfo?.primaryCommand)
169+
announce($t('command_palette.announcements.copied_to_clipboard'))
165170
},
166171
})
167172
}
@@ -175,6 +180,7 @@ useCommandPaletteContextCommands(
175180
iconClass: 'i-lucide:wand-sparkles',
176181
action: () => {
177182
copyCreateCommand()
183+
announce($t('command_palette.announcements.copied_to_clipboard'))
178184
},
179185
})
180186
}

app/composables/useCommandPaletteGlobalCommands.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,12 @@ export function useCommandPaletteGlobalCommands({
514514
t('command_palette.connections.npm_connected', { username: npmUsername }),
515515
],
516516
iconClass: 'i-lucide:plug-zap',
517-
action: closeThen(() => {
518-
disconnectNpm()
519-
}),
517+
action: runThenAnnounce(
518+
() => {
519+
disconnectNpm()
520+
},
521+
() => t('command_palette.announcements.npm_disconnected'),
522+
),
520523
},
521524
{
522525
id: 'my-packages',
@@ -572,9 +575,12 @@ export function useCommandPaletteGlobalCommands({
572575
}),
573576
],
574577
iconClass: 'i-lucide:log-out',
575-
action: closeThen(async () => {
576-
await logout()
577-
}),
578+
action: runThenAnnounce(
579+
async () => {
580+
await logout()
581+
},
582+
() => t('command_palette.announcements.atmosphere_disconnected'),
583+
),
578584
},
579585
{
580586
id: 'my-profile',

app/pages/compare.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ function exportComparisonDataAsMarkdown() {
136136
copy(markdown)
137137
}
138138
139+
const { announce } = useCommandPalette()
140+
139141
useCommandPaletteContextCommands(
140142
computed((): CommandPaletteContextCommandInput[] => {
141143
const commands: CommandPaletteContextCommandInput[] = [
@@ -147,6 +149,7 @@ useCommandPaletteContextCommands(
147149
iconClass: 'i-lucide:list-checks',
148150
action: () => {
149151
selectAll()
152+
announce($t('command_palette.announcements.facets_all_selected'))
150153
},
151154
},
152155
{
@@ -157,6 +160,7 @@ useCommandPaletteContextCommands(
157160
iconClass: 'i-lucide:list-x',
158161
action: () => {
159162
deselectAll()
163+
announce($t('command_palette.announcements.facets_all_deselected'))
160164
},
161165
},
162166
]
@@ -170,6 +174,7 @@ useCommandPaletteContextCommands(
170174
iconClass: 'i-lucide:copy',
171175
action: () => {
172176
exportComparisonDataAsMarkdown()
177+
announce($t('command_palette.announcements.copied_to_clipboard'))
173178
},
174179
})
175180
}
@@ -185,6 +190,11 @@ useCommandPaletteContextCommands(
185190
active: comparisonView.value === 'table',
186191
action: () => {
187192
comparisonView.value = 'table'
193+
announce(
194+
$t('command_palette.announcements.view_switched', {
195+
view: $t('compare.packages.table_view'),
196+
}),
197+
)
188198
},
189199
},
190200
{
@@ -196,6 +206,11 @@ useCommandPaletteContextCommands(
196206
active: comparisonView.value === 'charts',
197207
action: () => {
198208
comparisonView.value = 'charts'
209+
announce(
210+
$t('command_palette.announcements.view_switched', {
211+
view: $t('compare.packages.charts_view'),
212+
}),
213+
)
199214
},
200215
},
201216
)

i18n/locales/en.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,15 @@
176176
"theme_changed": "Theme set to {theme}.",
177177
"accent_color_changed": "Accent color set to {color}.",
178178
"background_theme_changed": "Background shade set to {theme}.",
179-
"download_started": "Downloading {package} tarball."
179+
"download_started": "Downloading {package} tarball.",
180+
"copied_to_clipboard": "Copied to clipboard.",
181+
"npm_disconnected": "npm CLI disconnected.",
182+
"atmosphere_disconnected": "Atmosphere disconnected.",
183+
"facets_all_selected": "All facets selected.",
184+
"facets_all_deselected": "All facets deselected.",
185+
"view_switched": "Switched to {view} view.",
186+
"setting_on": "{setting} on.",
187+
"setting_off": "{setting} off."
180188
}
181189
},
182190
"nav": {

i18n/locales/fr-FR.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,16 @@
175175
"relative_dates_off": "Dates relatives désactivées.",
176176
"theme_changed": "Thème {theme}.",
177177
"accent_color_changed": "Couleur d’accentuation {color}.",
178-
"background_theme_changed": "Couleur d’arrière-plan {theme}."
178+
"background_theme_changed": "Couleur d’arrière-plan {theme}.",
179+
"download_started": "Téléchargement du tarball de {package}.",
180+
"copied_to_clipboard": "Copié dans le presse-papiers.",
181+
"npm_disconnected": "npm CLI déconnecté.",
182+
"atmosphere_disconnected": "Atmosphere déconnecté.",
183+
"facets_all_selected": "Toutes les facettes sélectionnées.",
184+
"facets_all_deselected": "Toutes les facettes désélectionnées.",
185+
"view_switched": "Vue {view} activée.",
186+
"setting_on": "{setting} activé.",
187+
"setting_off": "{setting} désactivé."
179188
}
180189
},
181190
"nav": {

0 commit comments

Comments
 (0)