perf(a11y): add aria-label to language button (#2025)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/2054/head
Alija 2 years ago committed by GitHub
parent bed31d0c21
commit 322c633fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -389,4 +389,11 @@ Can be used to customize the sidebar menu label. This label is only displayed in
- Type: `string` - Type: `string`
- Default: `Return to top` - 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).

@ -2,8 +2,10 @@
import VPIconLanguages from './icons/VPIconLanguages.vue' import VPIconLanguages from './icons/VPIconLanguages.vue'
import VPFlyout from './VPFlyout.vue' import VPFlyout from './VPFlyout.vue'
import VPMenuLink from './VPMenuLink.vue' import VPMenuLink from './VPMenuLink.vue'
import { useData } from '../composables/data.js'
import { useLangs } from '../composables/langs.js' import { useLangs } from '../composables/langs.js'
const { theme } = useData()
const { localeLinks, currentLang } = useLangs({ correspondingLink: true }) const { localeLinks, currentLang } = useLangs({ correspondingLink: true })
</script> </script>
@ -12,6 +14,7 @@ const { localeLinks, currentLang } = useLangs({ correspondingLink: true })
v-if="localeLinks.length && currentLang.label" v-if="localeLinks.length && currentLang.label"
class="VPNavBarTranslations" class="VPNavBarTranslations"
:icon="VPIconLanguages" :icon="VPIconLanguages"
:label="theme.langMenuLabel || 'Change language'"
> >
<div class="items"> <div class="items">
<p class="title">{{ currentLang.label }}</p> <p class="title">{{ currentLang.label }}</p>

@ -98,6 +98,13 @@ export namespace DefaultTheme {
*/ */
returnToTopLabel?: string 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. * The algolia options. Leave it undefined to disable the search feature.
*/ */

Loading…
Cancel
Save