fix(components): [carousel] improve a11y (#15579)

* fix(a11y): carousel buttons do not have an accessible name

* fix: eslint warnings

* chore: change the label content

* feat: improve i18n
This commit is contained in:
Cloyd Lau 2024-02-03 14:03:41 +08:00 committed by GitHub
parent c46fe7f080
commit 73f4d0f57b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
60 changed files with 304 additions and 2 deletions

View File

@ -13,6 +13,7 @@
"
type="button"
:class="[ns.e('arrow'), ns.em('arrow', 'left')]"
:aria-label="t('el.carousel.leftArrow')"
@mouseenter="handleButtonEnter('left')"
@mouseleave="handleButtonLeave"
@click.stop="throttledArrowClick(activeIndex - 1)"
@ -30,6 +31,7 @@
"
type="button"
:class="[ns.e('arrow'), ns.em('arrow', 'right')]"
:aria-label="t('el.carousel.rightArrow')"
@mouseenter="handleButtonEnter('right')"
@mouseleave="handleButtonLeave"
@click.stop="throttledArrowClick(activeIndex + 1)"
@ -55,7 +57,10 @@
@mouseenter="throttledIndicatorHover(index)"
@click.stop="handleIndicatorClick(index)"
>
<button :class="ns.e('button')">
<button
:class="ns.e('button')"
:aria-label="t('el.carousel.indicator', { index: index + 1 })"
>
<span v-if="hasLabel">{{ item.props.label }}</span>
</button>
</li>
@ -67,7 +72,7 @@
import { computed, unref } from 'vue'
import { ElIcon } from '@element-plus/components/icon'
import { ArrowLeft, ArrowRight } from '@element-plus/icons-vue'
import { useNamespace } from '@element-plus/hooks'
import { useLocale, useNamespace } from '@element-plus/hooks'
import { carouselEmits, carouselProps } from './carousel'
import { useCarousel } from './use-carousel'
@ -103,6 +108,8 @@ const {
} = useCarousel(props, emit, COMPONENT_NAME)
const ns = useNamespace('carousel')
const { t } = useLocale()
const carouselClasses = computed(() => {
const classes = [ns.b(), ns.m(props.direction)]
if (unref(isCardType)) {

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -148,5 +148,10 @@ export default {
confirmButtonText: 'نعم',
cancelButtonText: 'لا',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -143,5 +143,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -126,5 +126,10 @@ export default {
empty: {
description: 'Məlumat yoxdur',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -125,5 +125,10 @@ export default {
confirmButtonText: 'হ্যা',
cancelButtonText: 'না',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -122,5 +122,10 @@ export default {
confirmButtonText: 'Sí',
cancelButtonText: 'No',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -161,5 +161,10 @@ export default {
confirmButtonText: 'بەڵێ',
cancelButtonText: 'نەخێر',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -125,5 +125,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -122,5 +122,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -129,5 +129,10 @@ export default {
confirmButtonText: 'Ja',
cancelButtonText: 'Nein',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -166,5 +166,10 @@ export default {
confirmButtonText: 'Yes',
cancelButtonText: 'No',
},
carousel: {
leftArrow: 'Carousel arrow left',
rightArrow: 'Carousel arrow right',
indicator: 'Carousel switch to index {index}',
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -122,5 +122,10 @@ export default {
confirmButtonText: 'Si',
cancelButtonText: 'No',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Jah',
cancelButtonText: 'Ei',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'بله',
cancelButtonText: 'خیر',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -160,5 +160,10 @@ export default {
confirmButtonText: 'Oui',
cancelButtonText: 'Non',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'כן',
cancelButtonText: 'לא',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -122,5 +122,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -125,5 +125,10 @@ export default {
confirmButtonText: 'Ya',
cancelButtonText: 'Tidak',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -122,5 +122,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'はい',
cancelButtonText: 'いいえ',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'យល់ព្រម',
cancelButtonText: 'មិនព្រម',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -156,5 +156,10 @@ export default {
confirmButtonText: '예',
cancelButtonText: '아니오',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -125,5 +125,10 @@ export default {
confirmButtonText: 'Eny',
cancelButtonText: 'Tsy',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -122,5 +122,10 @@ export default {
confirmButtonText: 'Ja',
cancelButtonText: 'Nei',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Ja',
cancelButtonText: 'Nee',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'Tak',
cancelButtonText: 'Nie',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'Sim',
cancelButtonText: 'Não',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'OK',
cancelButtonText: 'Отмена',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -125,5 +125,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Да',
cancelButtonText: 'Не',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'Ja',
cancelButtonText: 'Nej',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -162,5 +162,10 @@ export default {
confirmButtonText: 'ndio',
cancelButtonText: 'hapana',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -122,5 +122,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Evet',
cancelButtonText: 'Hayır',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -123,5 +123,10 @@ export default {
confirmButtonText: 'Yes', // to be translated
cancelButtonText: 'No', // to be translated
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -128,5 +128,10 @@ export default {
confirmButtonText: 'Ok',
cancelButtonText: 'Huỷ',
},
carousel: {
leftArrow: 'Carousel arrow left', // to be translated
rightArrow: 'Carousel arrow right', // to be translated
indicator: 'Carousel switch to index {index}', // to be translated
},
},
}

View File

@ -130,5 +130,10 @@ export default {
confirmButtonText: '确定',
cancelButtonText: '取消',
},
carousel: {
leftArrow: '上一张幻灯片',
rightArrow: '下一张幻灯片',
indicator: '幻灯片切换至索引 {index}',
},
},
}

View File

@ -164,5 +164,10 @@ export default {
confirmButtonText: '確認',
cancelButtonText: '取消',
},
carousel: {
leftArrow: '上一張投影片',
rightArrow: '下一張投影片',
indicator: '投影片切換至索引 {index}',
},
},
}