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

Commit 12b94e5

Browse files
committed
apply prettier
1 parent 14730c8 commit 12b94e5

File tree

4 files changed

+51
-22
lines changed

4 files changed

+51
-22
lines changed

docs/src/examples/components/Carousel/BestPractices/CarouselBestPractices.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const doList = [
1313
'Provide localized string of the "carousel" using `ariaRoleDescription` prop.',
1414
'Provide label to the carousel using `ariaLabel` prop.',
1515
<Box>
16-
If carousel contains `navigation`:
16+
If carousel contains `navigation`:
1717
<ul>
18-
<li> provide label to `navigation` and to navigation item using `aria-label` attribute</li>
18+
<li> provide label to `navigation` and to navigation item using `aria-label` attribute</li>
1919
<li> add `aria-controls` attribute to navigation item referencing to `carouselItem` id </li>
2020
</ul>
2121
</Box>,

packages/accessibility/src/behaviors/Carousel/carouselBehavior.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { Accessibility } from '../../types'
22
import * as keyboardKey from 'keyboard-key'
33

4-
54
/**
65
* @description
76
* Adds attribute 'role=region' to 'root' slot if 'navigation' property is false. Does not set the attribute otherwise.
87
* Adds attribute 'aria-roledescription' to 'root' slot if 'navigation' property is false. Does not set the attribute otherwise.
98
* Adds attribute 'aria-label' to 'root' slot if 'navigation' property is false. Does not set the attribute otherwise.
109
* Adds attribute 'aria-roledescription' to 'itemsContainer' slot if 'navigation' property is true. Does not set the attribute otherwise.
1110
* Adds attribute 'aria-label' to 'itemsContainer' slot if 'navigation' property is true. Does not set the attribute otherwise.
12-
*
11+
*
1312
* @specification
1413
* Adds attribute 'role=region' to 'root' slot.
1514
* Adds attribute 'aria-live=polite' to 'itemsContainerWrapper' slot if 'ariaLiveOn' property is true. Sets the attribute to 'off' otherwise.
@@ -26,7 +25,7 @@ import * as keyboardKey from 'keyboard-key'
2625
const carouselBehavior: Accessibility<CarouselBehaviorProps> = props => ({
2726
attributes: {
2827
root: {
29-
role: props.navigation ? undefined : 'region',
28+
role: props.navigation ? undefined : 'region',
3029
'aria-roledescription': props.navigation ? undefined : props.ariaRoleDescription,
3130
'aria-label': props.navigation ? undefined : props.ariaLabel,
3231
},
@@ -78,10 +77,9 @@ const carouselBehavior: Accessibility<CarouselBehaviorProps> = props => ({
7877
export type CarouselBehaviorProps = {
7978
/** Element type. */
8079
navigation: Object | Object[]
81-
ariaLiveOn: boolean
80+
ariaLiveOn: boolean
8281
ariaRoleDescription?: string
8382
ariaLabel?: string
84-
8583
}
8684

8785
export default carouselBehavior
Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
11
import { carouselBehavior } from '@fluentui/accessibility'
22

3-
const roleDescription = "carousel"
4-
const label = "portrait collection"
3+
const roleDescription = 'carousel'
4+
const label = 'portrait collection'
55

66
describe('carouselBehavior.ts', () => {
7-
87
describe('root', () => {
98
test(`sets "role=region" when carousel has NO navigation`, () => {
109
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: false })
1110
expect(expectedResult.attributes.root.role).toEqual('region')
1211
})
1312

1413
test('sets "aria-roledescription" when carousel has NO navigation', () => {
15-
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: false, ariaRoleDescription: roleDescription })
14+
const expectedResult = carouselBehavior({
15+
ariaLiveOn: false,
16+
navigation: false,
17+
ariaRoleDescription: roleDescription,
18+
})
1619
expect(expectedResult.attributes.root['aria-roledescription']).toEqual(roleDescription)
1720
})
1821

1922
test('sets "aria-label" when carousel has NO navigation', () => {
20-
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: false, ariaLabel: label })
23+
const expectedResult = carouselBehavior({
24+
ariaLiveOn: false,
25+
navigation: false,
26+
ariaLabel: label,
27+
})
2128
expect(expectedResult.attributes.root['aria-label']).toEqual(label)
2229
})
2330

2431
test('do NOT set "aria-roledescription" when carousel has navigation', () => {
25-
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: true, ariaRoleDescription: roleDescription })
32+
const expectedResult = carouselBehavior({
33+
ariaLiveOn: false,
34+
navigation: true,
35+
ariaRoleDescription: roleDescription,
36+
})
2637
expect(expectedResult.attributes.root['aria-roledescription']).toBeUndefined()
2738
})
2839

2940
test('do NOT set "aria-label" when carousel has navigation', () => {
30-
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: true, ariaLabel: label })
41+
const expectedResult = carouselBehavior({
42+
ariaLiveOn: false,
43+
navigation: true,
44+
ariaLabel: label,
45+
})
3146
expect(expectedResult.attributes.root['aria-label']).toBeUndefined()
3247
})
3348

@@ -39,22 +54,40 @@ describe('carouselBehavior.ts', () => {
3954

4055
describe('itemsContainer', () => {
4156
test('sets "aria-roledescription" when carousel has navigation', () => {
42-
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: true, ariaRoleDescription: roleDescription })
43-
expect(expectedResult.attributes.itemsContainer['aria-roledescription']).toEqual(roleDescription)
57+
const expectedResult = carouselBehavior({
58+
ariaLiveOn: false,
59+
navigation: true,
60+
ariaRoleDescription: roleDescription,
61+
})
62+
expect(expectedResult.attributes.itemsContainer['aria-roledescription']).toEqual(
63+
roleDescription,
64+
)
4465
})
4566

4667
test('sets "aria-label" when carousel has navigation', () => {
47-
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: true, ariaLabel: label })
68+
const expectedResult = carouselBehavior({
69+
ariaLiveOn: false,
70+
navigation: true,
71+
ariaLabel: label,
72+
})
4873
expect(expectedResult.attributes.itemsContainer['aria-label']).toEqual(label)
4974
})
5075

5176
test('do NOT set "aria-roledescription" when carousel has NO navigation', () => {
52-
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: false, ariaRoleDescription: roleDescription })
77+
const expectedResult = carouselBehavior({
78+
ariaLiveOn: false,
79+
navigation: false,
80+
ariaRoleDescription: roleDescription,
81+
})
5382
expect(expectedResult.attributes.itemsContainer['aria-roledescription']).toBeUndefined()
5483
})
5584

5685
test('do NOT set "aria-label" when carousel has NO navigation', () => {
57-
const expectedResult = carouselBehavior({ ariaLiveOn: false, navigation: false, ariaLabel: label })
86+
const expectedResult = carouselBehavior({
87+
ariaLiveOn: false,
88+
navigation: false,
89+
ariaLabel: label,
90+
})
5891
expect(expectedResult.attributes.itemsContainer['aria-label']).toBeUndefined()
5992
})
6093

@@ -63,6 +96,4 @@ describe('carouselBehavior.ts', () => {
6396
expect(expectedResult.attributes.itemsContainer.role).toBeUndefined()
6497
})
6598
})
66-
67-
6899
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class Carousel extends AutoControlledComponent<WithAsProp<CarouselProps>, Carous
241241
}
242242

243243
renderContent = (accessibility, styles, unhandledProps) => {
244-
const {getItemPositionText, items} = this.props
244+
const { getItemPositionText, items } = this.props
245245
const { activeIndex, itemIds } = this.state
246246

247247
this.itemRefs = []

0 commit comments

Comments
 (0)