Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 3639ce7

Browse files
committed
adding aria label as prop
1 parent 0104d59 commit 3639ce7

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

docs/src/examples/components/Carousel/Types/CarouselExample.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const carouselItems = [
3737
const CarouselExample = () => (
3838
<Carousel
3939
ariaRoleDescription="carousel"
40+
ariaLabel="Portrait collection"
4041
navigation={{
4142
'aria-label': 'people portraits',
4243
items: carouselItems.map((item, index) => ({

docs/src/examples/components/Carousel/Types/CarouselPaginationExample.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const carouselItems = [
2323
const CarouselExample = () => (
2424
<Carousel
2525
ariaRoleDescription="carousel"
26+
ariaLabel="Portrait collection"
2627
items={carouselItems}
2728
paddleNext={{ 'aria-label': 'go to next slide' }}
2829
paddlePrevious={{ 'aria-label': 'go to previous slide' }}

docs/src/examples/components/Carousel/Variations/CarouselCircularExample.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const CarouselExample = () => (
3434
<Carousel
3535
circular
3636
ariaRoleDescription="carousel"
37+
ariaLabel="Portrait collection"
3738
navigation={{
3839
'aria-label': 'people portraits',
3940
items: carouselItems.map((item, index) => ({

packages/react/src/components/Carousel/Carousel.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export interface CarouselProps extends UIComponentProps, ChildrenComponentProps
5252
*/
5353
ariaRoleDescription?: string
5454

55+
/**
56+
* Sets the aria-label attribute for carousel.
57+
*/
58+
ariaLabel?: string
59+
5560
/** Specifies if the process of switching slides is circular. */
5661
circular?: boolean
5762

@@ -128,6 +133,7 @@ class Carousel extends AutoControlledComponent<WithAsProp<CarouselProps>, Carous
128133
}),
129134
activeIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
130135
ariaRoleDescription: PropTypes.string,
136+
ariaLabel: PropTypes.string,
131137
circular: PropTypes.bool,
132138
defaultActiveIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
133139
getItemPositionText: PropTypes.func,
@@ -235,7 +241,7 @@ class Carousel extends AutoControlledComponent<WithAsProp<CarouselProps>, Carous
235241
}
236242

237243
renderContent = (accessibility, styles, unhandledProps) => {
238-
const { ariaRoleDescription, getItemPositionText, items } = this.props
244+
const { ariaRoleDescription, ariaLabel, getItemPositionText, items } = this.props
239245
const { activeIndex, itemIds } = this.state
240246

241247
this.itemRefs = []
@@ -245,7 +251,7 @@ class Carousel extends AutoControlledComponent<WithAsProp<CarouselProps>, Carous
245251
<div
246252
className={Carousel.slotClassNames.itemsContainer}
247253
aria-roledescription={ariaRoleDescription}
248-
aria-label="Portrait collection"
254+
aria-label={ariaLabel}
249255
style={styles.itemsContainer}
250256
{...accessibility.attributes.itemsContainer}
251257
{...applyAccessibilityKeyHandlers(

0 commit comments

Comments
 (0)