This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
feat(List): behavior, example and prototype for navigable list #1904
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
48115b5
accessibility for horizontal list
5586229
better prop types, add steps test
033e727
Merge branch 'master' into acc/horizontal-list-acc
3e0359e
changelog
86f9ec3
fix steps test
0067889
Merge branch 'master' into acc/horizontal-list-acc
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
docs/src/examples/components/List/Types/ListExampleNavigable.shorthand.steps.ts
This file contains hidden or 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,26 @@ | ||
| import { List } from '@stardust-ui/react' | ||
|
|
||
| const selectors = { | ||
| list: `.${List.className}`, | ||
| item: (itemIndex: number) => | ||
| `.${List.className} .${List.Item.className}:nth-of-type(${itemIndex})`, | ||
| } | ||
|
|
||
| const config: ScreenerTestsConfig = { | ||
| themes: ['teams', 'teamsDark', 'teamsHighContrast'], | ||
| steps: [ | ||
| (builder, keys) => | ||
| builder | ||
| .hover(selectors.item(2)) | ||
| .snapshot('Highlights an item') | ||
| .click(selectors.item(2)) | ||
| .snapshot('Clicks on an item') | ||
| .hover(selectors.item(3)) | ||
| .snapshot('Highlights another item') | ||
| .keys(selectors.item(2), keys.downArrow) | ||
| .snapshot('Focuses last item using keyboard'), | ||
| (builder, keys) => builder.keys('body', keys.tab).snapshot('Focuses item'), | ||
| ], | ||
| } | ||
|
|
||
| export default config |
30 changes: 30 additions & 0 deletions
30
docs/src/examples/components/List/Types/ListExampleNavigable.shorthand.tsx
This file contains hidden or 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 * as React from 'react' | ||
| import { List, Image } from '@stardust-ui/react' | ||
|
|
||
| const items = [ | ||
| { | ||
| key: 'irving', | ||
| media: <Image src="public/images/avatar/small/matt.jpg" avatar />, | ||
| header: 'Irving Kuhic', | ||
| headerMedia: '7:26:56 AM', | ||
| content: 'Program the sensor to the SAS alarm through the haptic SQL card!', | ||
| }, | ||
| { | ||
| key: 'skyler', | ||
| media: <Image src="public/images/avatar/small/steve.jpg" avatar />, | ||
| header: 'Skyler Parks', | ||
| headerMedia: '11:30:17 PM', | ||
| content: 'Use the online FTP application to input the multi-byte application!', | ||
| }, | ||
| { | ||
| key: 'dante', | ||
| media: <Image src="public/images/avatar/small/nom.jpg" avatar />, | ||
| header: 'Dante Schneider', | ||
| headerMedia: '5:22:40 PM', | ||
| content: 'The GB pixel is down, navigate the virtual interface!', | ||
| }, | ||
| ] | ||
|
|
||
| const ListExampleNavigable = () => <List navigable items={items} /> | ||
|
|
||
| export default ListExampleNavigable |
30 changes: 30 additions & 0 deletions
30
docs/src/examples/components/List/Types/ListExampleNavigable.tsx
This file contains hidden or 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 * as React from 'react' | ||
| import { List, Image } from '@stardust-ui/react' | ||
|
|
||
| const ListExampleNavigable = () => ( | ||
| <List navigable> | ||
| <List.Item | ||
| media={<Image src="public/images/avatar/small/matt.jpg" avatar />} | ||
| header="Irving Kuhic" | ||
| headerMedia="7:26:56 AM" | ||
| content="Program the sensor to the SAS alarm through the haptic SQL card!" | ||
| navigable | ||
| /> | ||
| <List.Item | ||
| media={<Image src="public/images/avatar/small/steve.jpg" avatar />} | ||
| header="Skyler Parks" | ||
| headerMedia="11:30:17 PM" | ||
| content="Use the online FTP application to input the multi-byte application!" | ||
| navigable | ||
| /> | ||
| <List.Item | ||
| media={<Image src="public/images/avatar/small/nom.jpg" avatar />} | ||
| header="Dante Schneider" | ||
| headerMedia="5:22:40 PM" | ||
| content="The GB pixel is down, navigate the virtual interface!" | ||
| navigable | ||
| /> | ||
| </List> | ||
| ) | ||
|
|
||
| export default ListExampleNavigable |
This file contains hidden or 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 hidden or 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,56 @@ | ||
| import React from 'react' | ||
| import { List, Avatar, Flex, Text, MenuButton, Icon } from '@stardust-ui/react' | ||
| import { PrototypeSection, ComponentPrototype } from '../Prototypes' | ||
|
|
||
| const menu = ['Open', 'Remove from list'] | ||
|
|
||
| const ActiveBarItem = props => ( | ||
| <Flex column hAlign="center" padding="padding.medium"> | ||
| <Avatar name={props.name} size="largest" /> | ||
| <Flex gap="gap.small"> | ||
| <Text content={props.name} /> | ||
| <MenuButton trigger={<Icon name="more" />} menu={menu} /> | ||
| </Flex> | ||
| </Flex> | ||
| ) | ||
|
|
||
| const addContextMenu = item => render => | ||
| render(item, (Component, props) => { | ||
| return <MenuButton contextMenu trigger={<Component {...props} />} menu={menu} /> | ||
| }) | ||
|
|
||
| const items3 = [ | ||
| { | ||
| key: 'irving', | ||
| content: <ActiveBarItem name="Irving Kuhic" />, | ||
| }, | ||
| { | ||
| key: 'skyler', | ||
| content: <ActiveBarItem name="Skyler Parks" />, | ||
| }, | ||
| { | ||
| key: 'dante', | ||
| content: <ActiveBarItem name="Dante Schneider" />, | ||
| }, | ||
| ].map(addContextMenu) | ||
|
|
||
| const ParticipantsList = () => ( | ||
| <> | ||
| <List navigable items={items3} horizontal /> | ||
| </> | ||
| ) | ||
|
|
||
| const ParticipantsListPrototype: React.FC = () => { | ||
| return ( | ||
| <PrototypeSection title="Participants list"> | ||
| <ComponentPrototype | ||
| title="List with context menu" | ||
| description="Context menu can be opened by clicking on the more button or by right mouse button" | ||
| > | ||
| <ParticipantsList /> | ||
| </ComponentPrototype> | ||
| </PrototypeSection> | ||
| ) | ||
| } | ||
|
|
||
| export default ParticipantsListPrototype |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
10 changes: 9 additions & 1 deletion
10
packages/react/src/lib/accessibility/Behaviors/List/listBehavior.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -1,20 +1,28 @@ | ||
| import { Accessibility } from '../../types' | ||
| import selectableListBehavior from './selectableListBehavior' | ||
| import basicListBehavior from './basicListBehavior' | ||
| import navigableListBehavior from './navigableListBehavior' | ||
|
|
||
| /** | ||
| * @description | ||
| * Defines a behavior 'BasicListBehavior' or 'SelectableListBehavior' based on property 'selectable'. | ||
| */ | ||
| const ListBehavior: Accessibility<ListBehaviorProps> = props => | ||
| props.selectable ? selectableListBehavior(props) : basicListBehavior(props) | ||
| props.selectable | ||
| ? selectableListBehavior(props) | ||
| : props.navigable | ||
| ? navigableListBehavior(props) | ||
| : basicListBehavior(props) | ||
|
|
||
| export default ListBehavior | ||
|
|
||
| export type ListBehaviorProps = { | ||
| /** Indicates if a list is a selectable list. */ | ||
| selectable?: boolean | ||
|
|
||
| /** Indicates if a list is a navigable list. */ | ||
| navigable?: boolean | ||
|
|
||
| /** Indicates if the list is horizontal. */ | ||
| horizontal?: boolean | ||
| } |
9 changes: 8 additions & 1 deletion
9
packages/react/src/lib/accessibility/Behaviors/List/listItemBehavior.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -1,19 +1,26 @@ | ||
| import selectableListItemBehavior from './selectableListItemBehavior' | ||
| import basicListItemBehavior from './basicListItemBehavior' | ||
| import { Accessibility } from '../../types' | ||
| import navigableListItemBehavior from './navigableListItemBehavior' | ||
|
|
||
| /** | ||
| * @description | ||
| * Defines a behavior "BasicListItemBehavior" or "SelectableListItemBehavior" based on "selectable" property. | ||
| */ | ||
| const listItemBehavior: Accessibility<ListItemBehaviorProps> = props => | ||
| props.selectable ? selectableListItemBehavior(props) : basicListItemBehavior(props) | ||
| props.selectable | ||
| ? selectableListItemBehavior(props) | ||
| : props.navigable | ||
| ? navigableListItemBehavior(props) | ||
| : basicListItemBehavior(props) | ||
|
|
||
| export default listItemBehavior | ||
|
|
||
| export type ListItemBehaviorProps = { | ||
| /** Indicates if a list is a selectable list. */ | ||
| selectable?: boolean | ||
| /** Indicates if a list is a navigable list. */ | ||
| navigable?: boolean | ||
| /** Indicates if the current list item is selected. */ | ||
| selected?: boolean | ||
| } |
26 changes: 26 additions & 0 deletions
26
packages/react/src/lib/accessibility/Behaviors/List/navigableListBehavior.ts
This file contains hidden or 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,26 @@ | ||
| import { Accessibility, FocusZoneMode } from '../../types' | ||
| import { ListBehaviorProps } from './listBehavior' | ||
| import { FocusZoneDirection } from '../../FocusZone' | ||
|
|
||
| /** | ||
| * @specification | ||
| * Adds role='menu'. | ||
| * Embeds component into FocusZone. | ||
| * Provides arrow key navigation in bidirectionalDomOrder direction. | ||
| */ | ||
| const navigableListBehavior: Accessibility<ListBehaviorProps> = props => ({ | ||
| attributes: { | ||
| root: { | ||
| role: 'menu', | ||
| }, | ||
| }, | ||
| focusZone: { | ||
| mode: FocusZoneMode.Embed, | ||
| props: { | ||
| shouldFocusInnerElementWhenReceivedFocus: true, | ||
| direction: FocusZoneDirection.bidirectionalDomOrder, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| export default navigableListBehavior |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.