Skip to content

Commit

Permalink
perf(a11y): add aria-label to language button (#2025)
Browse files Browse the repository at this point in the history
Co-authored-by: Divyansh Singh <[email protected]>
  • Loading branch information
sabicalija and brc-dd authored Mar 8, 2023
1 parent bed31d0 commit 322c633
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/reference/default-theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,11 @@ Can be used to customize the sidebar menu label. This label is only displayed in
- Type: `string`
- Default: `Return to top`

Can be used to customize the label of the returnToTop. This label is only displayed in the mobile view.
Can be used to customize the label of the return to top button. This label is only displayed in the mobile view.

## langMenuLabel

- Type: `string`
- Default: `Change language`

Can be used to customize the aria-label of the language toggle button in navbar. This is only used if you're using [i18n](../guide/i18n).
3 changes: 3 additions & 0 deletions src/client/theme-default/components/VPNavBarTranslations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import VPIconLanguages from './icons/VPIconLanguages.vue'
import VPFlyout from './VPFlyout.vue'
import VPMenuLink from './VPMenuLink.vue'
import { useData } from '../composables/data.js'
import { useLangs } from '../composables/langs.js'
const { theme } = useData()
const { localeLinks, currentLang } = useLangs({ correspondingLink: true })
</script>

Expand All @@ -12,6 +14,7 @@ const { localeLinks, currentLang } = useLangs({ correspondingLink: true })
v-if="localeLinks.length && currentLang.label"
class="VPNavBarTranslations"
:icon="VPIconLanguages"
:label="theme.langMenuLabel || 'Change language'"
>
<div class="items">
<p class="title">{{ currentLang.label }}</p>
Expand Down
7 changes: 7 additions & 0 deletions types/default-theme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ export namespace DefaultTheme {
*/
returnToTopLabel?: string

/**
* Set custom `aria-label` for language menu button.
*
* @default 'Change language'
*/
langMenuLabel?: string

/**
* The algolia options. Leave it undefined to disable the search feature.
*/
Expand Down

0 comments on commit 322c633

Please sign in to comment.