forked from cerner/terra-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[terra-list] Add programmatic context for list instructions (cerner#3688
) This change adds ariaDescribedBy, ariaDescription, and ariaDetails props by which consumers can provide information and instructions about how to interact with a list so that screen readers are able to convey the information to the user. UXPLATFORM-7596
- Loading branch information
Showing
15 changed files
with
498 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/terra-core-docs/src/terra-dev-site/doc/list/example/AriaDescribedByHiddenList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
import { Placeholder } from '@cerner/terra-docs'; | ||
import VisuallyHiddenText from 'terra-visually-hidden-text'; | ||
import classNames from 'classnames/bind'; | ||
import styles from './ListDocCommon.module.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
const AriaDescribedByHiddenList = () => ( | ||
<> | ||
<VisuallyHiddenText | ||
id="list-help" | ||
text="Select a patient from the list to view patient details." | ||
/> | ||
<List ariaDescribedBy="list-help"> | ||
<Item key="123"> | ||
<Placeholder title="John Smith" className={cx('placeholder')} /> | ||
</Item> | ||
<Item key="124"> | ||
<Placeholder title="Mary Jones" className={cx('placeholder')} /> | ||
</Item> | ||
<Item key="125"> | ||
<Placeholder title="Sam Brown" className={cx('placeholder')} /> | ||
</Item> | ||
</List> | ||
</> | ||
); | ||
|
||
export default AriaDescribedByHiddenList; |
28 changes: 28 additions & 0 deletions
28
packages/terra-core-docs/src/terra-dev-site/doc/list/example/AriaDescribedByVisibleList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
import { Placeholder } from '@cerner/terra-docs'; | ||
import classNames from 'classnames/bind'; | ||
import styles from './ListDocCommon.module.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
const AriaDescribedByVisibleList = () => ( | ||
<> | ||
<p id="list-help"> | ||
Select a patient from the list to view patient details. | ||
</p> | ||
<List ariaDescribedBy="list-help"> | ||
<Item key="123"> | ||
<Placeholder title="John Smith" className={cx('placeholder')} /> | ||
</Item> | ||
<Item key="124"> | ||
<Placeholder title="Mary Jones" className={cx('placeholder')} /> | ||
</Item> | ||
<Item key="125"> | ||
<Placeholder title="Sam Brown" className={cx('placeholder')} /> | ||
</Item> | ||
</List> | ||
</> | ||
); | ||
|
||
export default AriaDescribedByVisibleList; |
23 changes: 23 additions & 0 deletions
23
packages/terra-core-docs/src/terra-dev-site/doc/list/example/AriaDescriptionList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
import { Placeholder } from '@cerner/terra-docs'; | ||
import classNames from 'classnames/bind'; | ||
import styles from './ListDocCommon.module.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
const AriaDescriptionList = () => ( | ||
<List ariaDescription="Select a patient from the list to view patient details."> | ||
<Item key="123"> | ||
<Placeholder title="John Smith" className={cx('placeholder')} /> | ||
</Item> | ||
<Item key="124"> | ||
<Placeholder title="Mary Jones" className={cx('placeholder')} /> | ||
</Item> | ||
<Item key="125"> | ||
<Placeholder title="Sam Brown" className={cx('placeholder')} /> | ||
</Item> | ||
</List> | ||
); | ||
|
||
export default AriaDescriptionList; |
28 changes: 28 additions & 0 deletions
28
packages/terra-core-docs/src/terra-dev-site/doc/list/example/AriaDetailsList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
import { Placeholder } from '@cerner/terra-docs'; | ||
import classNames from 'classnames/bind'; | ||
import styles from './ListDocCommon.module.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
const AriaDetailsList = () => ( | ||
<> | ||
<p id="list-details"> | ||
Select a patient from the list to view patient details. | ||
</p> | ||
<List ariaDetails="list-details"> | ||
<Item key="123"> | ||
<Placeholder title="John Smith" className={cx('placeholder')} /> | ||
</Item> | ||
<Item key="124"> | ||
<Placeholder title="Mary Jones" className={cx('placeholder')} /> | ||
</Item> | ||
<Item key="125"> | ||
<Placeholder title="Sam Brown" className={cx('placeholder')} /> | ||
</Item> | ||
</List> | ||
</> | ||
); | ||
|
||
export default AriaDetailsList; |
25 changes: 25 additions & 0 deletions
25
packages/terra-core-docs/src/terra-dev-site/test/list/AriaDescribedByHiddenList.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
import VisuallyHiddenText from 'terra-visually-hidden-text'; | ||
|
||
const AriaDescribedByHiddenListTest = () => ( | ||
<> | ||
<VisuallyHiddenText | ||
id="list-help" | ||
text="Select a patient from the list to view patient details." | ||
/> | ||
<List ariaDescribedBy="list-help"> | ||
<Item key="0"> | ||
<p>John Smith</p> | ||
</Item> | ||
<Item key="1"> | ||
<p>Mary Jones</p> | ||
</Item> | ||
<Item key="2"> | ||
<p>Sam Brown</p> | ||
</Item> | ||
</List> | ||
</> | ||
); | ||
|
||
export default AriaDescribedByHiddenListTest; |
33 changes: 33 additions & 0 deletions
33
packages/terra-core-docs/src/terra-dev-site/test/list/AriaDescribedBySelectableList.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useState } from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
|
||
const AriaDescribedBySelectableListTest = () => { | ||
const [selected, setSelected] = useState({ selectedKey: null }); | ||
|
||
const handleSelectItem = (event, metaData) => { | ||
if (selected.selectedKey !== metaData.key) { | ||
setSelected({ selectedKey: metaData.key }); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<p id="list-help"> | ||
Select a patient from the list to view patient details. | ||
</p> | ||
<List ariaDescribedBy="list-help" role="listbox"> | ||
<Item key="1" isSelectable isSelected={selected.selectedKey === '1'} metaData={{ key: '1' }} onSelect={handleSelectItem}> | ||
<p>John Smith</p> | ||
</Item> | ||
<Item key="2" isSelectable isSelected={selected.selectedKey === '2'} metaData={{ key: '2' }} onSelect={handleSelectItem}> | ||
<p>Mary Jones</p> | ||
</Item> | ||
<Item key="3" isSelectable isSelected={selected.selectedKey === '3'} metaData={{ key: '3' }} onSelect={handleSelectItem}> | ||
<p>Sam Brown</p> | ||
</Item> | ||
</List> | ||
</> | ||
); | ||
}; | ||
|
||
export default AriaDescribedBySelectableListTest; |
23 changes: 23 additions & 0 deletions
23
packages/terra-core-docs/src/terra-dev-site/test/list/AriaDescribedByVisibleList.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
|
||
const AriaDescribedByVisibleListTest = () => ( | ||
<> | ||
<p id="list-help"> | ||
Select a patient from the list to view patient details. | ||
</p> | ||
<List ariaDescribedBy="list-help"> | ||
<Item key="0"> | ||
<p>John Smith</p> | ||
</Item> | ||
<Item key="1"> | ||
<p>Mary Jones</p> | ||
</Item> | ||
<Item key="2"> | ||
<p>Sam Brown</p> | ||
</Item> | ||
</List> | ||
</> | ||
); | ||
|
||
export default AriaDescribedByVisibleListTest; |
18 changes: 18 additions & 0 deletions
18
packages/terra-core-docs/src/terra-dev-site/test/list/AriaDescriptionList.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
|
||
const AriaDescriptionListTest = () => ( | ||
<List ariaDescription="Select a patient from the list to view patient details."> | ||
<Item key="0"> | ||
<p>John Smith</p> | ||
</Item> | ||
<Item key="1"> | ||
<p>Mary Jones</p> | ||
</Item> | ||
<Item key="2"> | ||
<p>Sam Brown</p> | ||
</Item> | ||
</List> | ||
); | ||
|
||
export default AriaDescriptionListTest; |
23 changes: 23 additions & 0 deletions
23
packages/terra-core-docs/src/terra-dev-site/test/list/AriaDetailsList.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import List, { Item } from 'terra-list/lib/index'; | ||
|
||
const AriaDetailsListTest = () => ( | ||
<> | ||
<p id="list-details"> | ||
Select a patient from the list to view patient details. | ||
</p> | ||
<List ariaDetails="list-details"> | ||
<Item key="0"> | ||
<p>John Smith</p> | ||
</Item> | ||
<Item key="1"> | ||
<p>Mary Jones</p> | ||
</Item> | ||
<Item key="2"> | ||
<p>Sam Brown</p> | ||
</Item> | ||
</List> | ||
</> | ||
); | ||
|
||
export default AriaDetailsListTest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.